This repo contains the code for the NHS Prototype kit that will be distributed as an npm package.
The code contains:
- an Express middleware app
- some useful default settings for Express
- some Nunjucks filters
- Nunjucks views, including a template
The simplest way to get started is to use the NHS Prototype kit template repository.
From there, select 'Use this as a template' and follow the instructions.
You can also add the kit to an existing Express app by running:
npm install nhsuk-prototype-kit
Then, within your app.js file, add this line to the top:
const NHSPrototypeKit = require('nhsuk-prototype-kit')and then after your app and nunjucks configuration code, add this:
const prototype = NHSPrototypeKit.init({
serviceName: 'Your service name',
express: app,
nunjucks: nunjucks,
routes: routes,
sessionDataDefaults: sessionDataDefaults
})You can then start the prototype using this:
prototype.start()If you only want to use the Nunjucks filters, you can use this:
NHSPrototypeKit.nunjucksFilters.addAll(nunjucksEnv)If you only want to use the Express middleware, you can do this to use everything:
app.use(NHSPrototypeKit.expressMiddleware.all({
serviceName: 'Your service name',
routes: routes,
locals: locals,
sessionDataDefaults: sessionDataDefaults
}))Or you can choose to only use individual middleware functions like this:
app.use(NHSPrototypeKit.expressMiddleware.autoRouting)