/hapi-govuk-examples

Examples of what we have learned from the permit POC

Primary LanguageJavaScriptOtherNOASSERTION

Hapi Govuk examples

An introduction to building a hapi service using the govuk plugins (by example) for the hapi Node.js framework.

Please note these examples have been developed from what was learned while developing the permitting proof of concept which is a good reference point if anything is not clear here.

Prerequisites

The hapi-govuk plugins:

Other essential plugins:


hapi-govuk-frontend

Provides a simple way to configure the locations of static files, dynamic view layouts and view partials for a hapi server.

The plugin assumes that Nunjucks will be used as the view engine.

The govuk-frontend npm module should be installed as a peer dependency.

Front end examples:


hapi-govuk-journey-map

Provides a way to organise the routes in a hapi server into reusable modules. Using mapping files, the plugin also provides a way to create journeys within and between each module instance.

Journey map examples:

  • Journey map example introduction

    • Introduction to the journey map
  • Journey map example part 1

    • Without using the Journey map plugin, add a continue button using the nunjucks macro govukButton.
    • Clicking the button should redirect to the next page in the journey.
  • Journey map example part 2

    • Again without using the Journey map plugin, create a question page including the nunjucks macro govukRadios and again include a continue button as above to redirect to the next page in the journey.
  • Journey map example part 3

    • One more time without using the Journey map plugin, create a completed page including the nunjucks macro govukPanel.
  • Journey map example part 4

    • Introduce the @envage/hapi-govuk-journey-map plugin.
    • Create a map file to configure the journey between routes.
    • Rearrange the location of the views and routes into a module folder.
  • Journey map example part 5

    • Configure the map file to allow branching the journey based on the answer given in the question page.
  • Journey map example part 6

    • Introduce the concept of modules to allow re-use of routes and views.
    • Move the question route into a new question module.
    • Include a new comment route within the question module.
    • Create a map file within the question module.
    • Configure the main map file to use the question module.
  • Journey map example part 7

    • Introduce the concept of module options as a means of configuring a module.
    • Add the options to the registration of the question module within the main map file.
    • Change the route files for both the question and comment routes to use the options.
  • Journey map example part 8

    • Re-use the question module by registering it twice more in the main map file with different module options.

hapi-govuk-question-page

Provides a configuration-driven approach to implementing simple pages using the GOV.UK Design System.

Question page examples:

Contributing to this project

If you have an idea you'd like to contribute please log an issue.

All contributions should be submitted via a pull request.

License

THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:

http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3

The following attribution statement MUST be cited in your products and applications when using this information.

Contains public sector information licensed under the Open Government license v3

About the license

The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.

It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.