-
Notifications
You must be signed in to change notification settings - Fork 80
/
index.js
51 lines (46 loc) · 1.17 KB
/
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
44
45
46
47
48
49
50
51
const path = require('path');
const nconf = require('nconf');
const logger = require('./server/lib/logger');
// eslint-disable-next-line import/no-extraneous-dependencies
require('@babel/register')({
ignore: [ /node_modules/ ],
sourceMaps: !(process.env.NODE_ENV === 'production'),
plugins: [
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-object-rest-spread'
],
presets: [
[ '@babel/env', {
targets: {
node: 'current'
}
} ]
]
});
// eslint-disable-next-line import/no-extraneous-dependencies
require('@babel/polyfill');
// Handle uncaught.
process.on('uncaughtException', (err) => {
logger.error(err);
});
// Initialize configuration.
nconf
.argv()
.env()
.file(path.join(__dirname, './server/config.json'))
.defaults({
NODE_ENV: 'development',
HOSTING_ENV: 'default',
PORT: 3001,
WT_URL: 'http://localhost:3000'
});
// Start the server.
const app = require('./server').default((key) => nconf.get(key), null);
const port = nconf.get('PORT');
app.listen(port, (error) => {
if (error) {
logger.error(error);
} else {
logger.info(`Listening on http://localhost:${port}.`);
}
});