-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·53 lines (44 loc) · 1.41 KB
/
Copy pathapp.js
File metadata and controls
executable file
·53 lines (44 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const NHSPrototypeKit = require('nhsuk-prototype-kit')
// Local dependencies
const config = require('./app/config')
const locals = require('./app/locals')
const routes = require('./app/routes')
const sessionDataDefaults = require('./app/data/session-data-defaults')
const filters = require('./app/filters')
// Set configuration variables
const port = parseInt(process.env.PORT || config.port, 10) || 2000
// Initialise applications
const viewsPath = [
'app/views/',
'app/views/_templates/',
'app/views/_includes/'
]
const entryPoints = [
'app/assets/sass/main.scss',
'app/assets/javascript/*.js',
// Not a real build target: the kit adds every entry point to nodemon's
// ignore list, and without this glob each seed data regeneration (which
// writes app/data/generated/*.json) would restart the server. The
// public/data/generated/*.js files esbuild emits as a result are an
// unused side effect.
'app/data/generated/**/*.json'
]
async function init() {
const prototype = await NHSPrototypeKit.init({
serviceName: config.serviceName,
buildOptions: {
entryPoints
},
viewsPath,
routes,
locals,
filters,
sessionDataDefaults
})
// Temporary: expose filters as globals until kit supports globals directly
for (const [name, global] of Object.entries(filters(prototype.nunjucks))) {
prototype.nunjucks.addGlobal(name, global)
}
prototype.start(port)
}
init()