-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathhttp.js
More file actions
executable file
·38 lines (31 loc) · 1.11 KB
/
Copy pathhttp.js
File metadata and controls
executable file
·38 lines (31 loc) · 1.11 KB
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
#! /usr/bin/env node
const program = require('commander')
const pkg = require('../package.json')
const path = require('path')
const mkServer = require('../src/http')
/// /////////////////////////////////////////////////////////////////
// Initialize CLI
program
.version(pkg.version)
.option('-H, --host [host]', 'host to bind [127.0.0.1]', '127.0.0.1')
.option('-p, --port [port]', 'port to bind [4444]', '4444')
.option('-c, --conf [path]', 'validator configuration file [rules.json]')
program.on('--help', function () {
console.log(' Examples:')
console.log('')
console.log(' $ node bin/http.js -H 0.0.0.0 -p 8888')
console.log('')
})
program.parse(process.argv)
/// /////////////////////////////////////////////////////////////////
// Initialize Validator
var config = null
if (program['conf']) {
var configPath = path.resolve(process.cwd(), program['conf'])
config = require(configPath)
}
var server = mkServer(config)
server.listen(program['port'], program['host'], function () {
console.log(`[http] listening to ${program['host']}:${program['port']}`)
})
module.exports = server