-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.js
More file actions
72 lines (66 loc) · 1.87 KB
/
Copy pathapp.js
File metadata and controls
72 lines (66 loc) · 1.87 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import autoprefixer from 'autoprefixer'
import sessionInDatabase from 'connect-pg-simple'
import { sassPlugin } from 'esbuild-sass-plugin'
import session from 'express-session'
import NHSPrototypeKit, { config } from 'nhsuk-prototype-kit'
import { Pool } from 'pg'
import postcss from 'postcss'
import sessionDataDefaults from './app/data.js'
import filters from './app/filters.js'
import globals from './app/globals.js'
import routes from './app/routes.js'
const { DATABASE_URL, NODE_ENV } = process.env
const processor = postcss([
autoprefixer({
env: 'stylesheets'
})
])
const prototype = await NHSPrototypeKit.init({
buildOptions: {
entryPoints: [
'app/assets/stylesheets/*.scss',
'app/assets/javascripts/*.js'
],
external: ['/nhsuk-prototype-kit/*'],
plugins: [
sassPlugin({
embedded: true,
loadPaths: config.modulePaths,
quietDeps: true,
sourceMap: true,
sourceMapIncludeSources: true,
async transform(css, resolveDir, filePath) {
const result = await processor.process(css, {
from: filePath
})
return result.css
}
})
],
tsconfigRaw: {}
},
filters,
globals,
routes,
serviceName: 'Manage vaccinations in schools',
...(DATABASE_URL && {
session: session({
cookie: {
maxAge: 1000 * 60 * 60 * 4, // 4 hours
secure: NODE_ENV === 'production'
},
resave: false,
saveUninitialized: false,
secret: 'manage-vaccinations-in-schools-prototype',
store: new (sessionInDatabase(session))({
pool: new Pool({
connectionString: DATABASE_URL,
ssl: NODE_ENV === 'production' ? { rejectUnauthorized: false } : false
})
})
})
}),
sessionDataDefaults,
viewsPath: ['app', 'app/views', 'node_modules/nhsuk-decorated-components']
})
prototype.start()