-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
37 lines (27 loc) · 907 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
const debug = require('debug')('mvc-webapp:server')
const core = require('./core.js')
exports.run = async function (options) {
validateOptions(options)
const app = await core.create(options)
debug('port', options.listenPort)
app.listen(options.listenPort)
return app
}
exports.test = function (options) {
validateOptions(options)
return core.create(options)
}
function validateOptions(options) {
// Options are enforced as opposed to reasonable defaults
// This may change in the future
if (typeof options.applicationRoot === 'undefined') {
throw new TypeError('Application root must be defined.')
}
if (typeof options.listenPort === 'undefined') {
throw new TypeError('Listening port must be defined.')
}
if (typeof options.sessionSecret === 'undefined'
&& typeof options.sessionRedisUrl !== 'undefined') {
throw new TypeError('A session secret salt must be defined.')
}
}