-
Notifications
You must be signed in to change notification settings - Fork 16
/
server.js
40 lines (31 loc) · 1.14 KB
/
server.js
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
// Core dependencies
const path = require('path')
const express = require('express')
// Application
const app = express()
// Force https in production
const useHttpsInProd = require('./app/lib/use-https-in-production')
useHttpsInProd(app)
// Configure markdown
const markdown = require('./app/lib/markdown')
markdown.setup()
// Configure nunjucks
const nunjucks = require('./app/lib/nunjucks')
nunjucks.setup(app)
// Routing
const redirects = require('./app/routes/redirects')
const routes = require('./app/routes/index')
const autoRoutes = require('./app/routes/auto')
// Middleware to serve static assets
app.use('/public', express.static(path.join(__dirname, '/public')))
app.use('/evaluations', express.static(path.join(__dirname, '/evaluations')))
app.use('/assets', express.static(path.join(__dirname, 'node_modules', 'govuk-frontend', 'govuk', 'assets')))
app.use('/node_modules/govuk-frontend', express.static(path.join(__dirname, '/node_modules/govuk-frontend/govuk')))
// Use routes
app.use(redirects)
app.use(routes)
app.use(autoRoutes)
// Start server
const serverStart = require('./app/lib/server-start')
serverStart(app)
module.exports = app