{"id":20038655,"url":"https://github.com/defra/hapi-govuk-question-page","last_synced_at":"2025-05-05T07:32:07.803Z","repository":{"id":52414519,"uuid":"227914785","full_name":"DEFRA/hapi-govuk-question-page","owner":"DEFRA","description":"A Hapi plugin that provides a configuration-driven approach to implementing simple pages using the GOV.UK Design System","archived":false,"fork":false,"pushed_at":"2022-03-18T09:51:54.000Z","size":236,"stargazers_count":2,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-06T16:16:06.229Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DEFRA.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-13T20:13:38.000Z","updated_at":"2024-04-23T04:46:14.000Z","dependencies_parsed_at":"2022-08-21T11:30:15.372Z","dependency_job_id":null,"html_url":"https://github.com/DEFRA/hapi-govuk-question-page","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fhapi-govuk-question-page","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fhapi-govuk-question-page/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fhapi-govuk-question-page/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fhapi-govuk-question-page/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DEFRA","download_url":"https://codeload.github.com/DEFRA/hapi-govuk-question-page/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224431235,"owners_count":17310067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T10:31:33.300Z","updated_at":"2024-11-13T10:31:34.092Z","avatar_url":"https://github.com/DEFRA.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hapi Simple GOV.UK Question Page\n\nThe **hapi-govuk-question-page** module is a plugin for [Hapi](https://hapi.dev/) that provides a configuration-driven\napproach to implementing simple pages using the [GOV.UK Design System](https://design-system.service.gov.uk/).\n\nIt is based on the original work for the [digital-form-builder](https://github.com/DEFRA/digital-form-builder).\n\nThe [API documentation](API.md) contains details of how to configure the plugin.\n\n## Purpose\n\nWe have a wide range of services, many involving quite lengthy and complex interactions with our users.\nAs we break these interactions down into simple steps to make them as easy as possible to use,\nwe often end up with a service journey that includes a large number of quite simple\n[question pages](https://design-system.service.gov.uk/patterns/question-pages).\n\nThis plugin is designed to help create those simple pages, by providing these two features:\n  - A way to implement pages by just listing the components that need to appear on them and providing a minimal\n    amount of configuration information.\n  - A basic request handler that just deals with processing the page requests and validating the inputs.\n\nThose features are already met by a combination of Nunjucks, the GOV.UK Design System and the Hapi request lifecycle,\nbut using them out of the box results in a lot of repeated, boilerplate code and templates.\n\nThe purpose of this plugin is to put all of that boilerplate into one place where it can be tested once and reused\nmultiple times.\n\n## GOV.UK Design System components and patterns\n\nThe plugin provides an implementation of the Question Page pattern and *most* of the components and patterns from\nthe Design System. Those not included are:\n - Components such as the Back Link or Error Summary that are built into the page and do not need to be added\n   separately.\n - The Accordian and Tabs components, as these are not *simple* question pages and would make the configuration\n   probably more complex than the equivalent code.\n - Components and patterns such as the Panel, the Summary List, Confirmation Pages and Task List Pages that are not\n   required for a Question Page.\n - Patterns such as National Insurance Numbers that we haven't found a need for yet.\n - Patterns such as Addresses and Confirm an Email Address that require more complex interaction design and\n   functionality than a simple question page.\n\n## Prerequisites\n\nThis plugin is for use inside a Hapi GOV.UK application.  To use it, you will need to create an application\nbased on the following:\n- [Node.js](https://nodejs.org)\n- [Hapi](https://hapi.dev/)\n- The Hapi [Vision](https://github.com/hapijs/vision) plugin, configured to use:\n  - [Nunjucks](https://mozilla.github.io/nunjucks/)\n  - The [GOV.UK Frontend](https://github.com/alphagov/govuk-frontend)\n\nSpecific versions of these dependencies are identified in the package.json.\n\n## Setup\n\nTo use this plugin in your application, simply\n\n\u003e `npm install @envage/hapi-govuk-question-page`\n\nRegister the plugin with your Hapi server, as with any other plugin\n\n\u003e `await server.register(require('@envage/hapi-govuk-question-page'))`\n\nThis adds a custom `hapi-govuk-question-page` handler to your server that you can use in your routes\n\n\u003e ```js\n\u003e  server.route({\n\u003e    method: ['GET', 'POST'],\n\u003e    path: '/',\n\u003e    handler: {\n\u003e      'hapi-govuk-question-page': {\n\u003e        pageDefinition,\n\u003e        getData,\n\u003e        setData,\n\u003e        getNextPath,\n\u003e      }\n\u003e    }\n\u003e  })\n\u003e ```\n\nFor pages to be correctly served, you will also have to perform setup of Vision, Nunjucks and the GOV.UK Frontend.\nDetails on this are in the [API documentation](API.md).\n\n### Development and Test\n\nWhen developing this plugin, simply clone this repository\n\n\u003e `git clone https://github.com/DEFRA/hapi-govuk-question-page.git`\n\nand run\n\n\u003e `npm install`\n\n## Running in development\n\nThe project includes a test harness that shows the different form components on a single page.\nThis can be run using\n\n\u003e `npm run test-harness`\n\nand then navigating in your browser to http://localhost:3000\n\n## Running tests\n\nUnit tests can be run using\n\n\u003e `npm run unit-test`\n\n## Contributing to this project\n\nIf you have an idea you'd like to contribute please log an issue.\n\nAll contributions should be submitted via a pull request.\n\nNote that we use [Standard JS](https://standardjs.com/) style, you can check your code using\n\n\u003e `npm run lint`\n\n## Licence\n\nTHIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:\n\n\u003chttp://www.nationalarchives.gov.uk/doc/open-government-licence/version/3\u003e\n\nThe following attribution statement MUST be cited in your products and applications when using this information.\n\n\u003e Contains public sector information licensed under the Open Government licence v3\n\n### About the licence\n\nThe Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable\ninformation providers in the public sector to license the use and re-use of their information under a common open\nlicence.\n\nIt is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fhapi-govuk-question-page","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefra%2Fhapi-govuk-question-page","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fhapi-govuk-question-page/lists"}