-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
36 lines (29 loc) · 977 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
// Initialize nconf with proper config
require('./nconf')
const _ = require('lodash')
const path = require('path')
const EventEmitter = require('events').EventEmitter
const errorApp = require('./error')
const server = require('./server')
const ROOT_PATH = process.env.ROOT_PATH || process.cwd()
module.exports = (options = {}, cb) => {
// Set project dir to process.cwd(). In future we may want to allow to
// allow the customization of this parameter.
options.dirname = ROOT_PATH
_.defaults(options, {
appRoutes: {},
publicPath: './public',
loginUrl: '/login',
websockets: true,
bodyParserLimit: '10mb',
error: errorApp
})
// Transform public path to be absolute
options.publicPath = path.resolve(options.dirname, options.publicPath)
// Run cb to setup additional options that require initialized nconf
// and do event handling
options.ee = new EventEmitter()
cb && cb(options.ee, options)
// Run app
server(options)
}