-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·32 lines (28 loc) · 888 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
#!/usr/bin/env node
const argv = require('yargs').argv,
server = require('./lib/server'),
logger = require('./lib/logger'),
getConfig = require('./lib/config'),
listen = require('./lib/listen');
const defaultConfig = {
path: './',
port: 3000,
https: true
},
configFromFile = getConfig(argv.config),
config = Object.assign({}, defaultConfig, configFromFile, argv);
logger.info('config parsed successfully');
try {
// cli args all come in as strings, we need these types to be correct
config.https = JSON.parse(config.https);
config.port = JSON.parse(config.port);
} catch (ex) {
logger.error('encountered an issue parsing arguments\n');
throw ex;
}
server(config)
.then(server => listen(server, config))
.catch(err => {
!err.known && logger.error('unexpected error\n');
throw err;
});