forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.js
More file actions
28 lines (22 loc) · 695 Bytes
/
Server.js
File metadata and controls
28 lines (22 loc) · 695 Bytes
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
const { join, resolve } = require('path')
const express = require('express')
const bodyParser = require('body-parser')
const staticPath = join(resolve(process.cwd()), 'public')
function Server() {
const server = express()
server.use(bodyParser.json())
server.disable('x-powered-by')
server.set('trust proxy', true)
server.get('/alive', (_req, res) => {
res.json({ status: 'ok' })
})
server.get('/ready', (_req, res) => {
res.json({ status: 'ready' })
})
server.use('/', express.static(staticPath, { maxage: '365d' }))
server.get('*', (_req, res) => {
res.sendFile(resolve(join('public', 'index.html')))
})
return server
}
module.exports.Server = Server