-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (36 loc) · 871 Bytes
/
index.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
41
42
43
'use strict'
if (process.env.NODE_ENV === 'development') {
require('dotenv').config()
}
const Hapi = require('hapi')
const server = Hapi.server({
host: process.env.HOST || '0.0.0.0',
port: process.env.PORT || 4000,
routes: {
cors: {
// TODO put these in with their respective routes
additionalHeaders: [
'x-cfp-year',
'x-cfp-stage',
'x-spreadsheet-id',
'x-sheet-name'
]
}
}
})
const middlewares = [
require('./src/http/middlewares/no-cookies'),
require('./src/http/middlewares/authentication')
]
const resources = require('./src/http/resources')
async function start () {
try {
await server.register(middlewares.concat(resources))
await server.start()
} catch (err) {
console.error(err)
process.exit(1)
}
console.info('Server running at:', server.info.uri)
};
start()