-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
vbb-rest
executable file
·53 lines (37 loc) · 1.05 KB
/
vbb-rest
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
52
53
#!/usr/bin/env coffee
minimist = require 'minimist'
fs = require 'fs'
argv = minimist process.argv.slice 2
help = [
'Usage:'
'vbb-rest -c <cert> -k <key> [-p <port>]'
''
'Arguments:'
' -c, --cert The SSL certificate.'
' -k, --key The SSL key.'
''
'Options:'
' -p, --port Where the server will listen. Default: 8000'
].join '\n'
if argv.h is true or argv.help is true
process.stdout.write help
process.exit 0
cert = null
if argv.c? then cert = argv.c
else if argv.cert? then cert = argv.cert
else throw new Error 'Missing `--cert` argument.'
cert = fs.readFileSync cert
key = null
if argv.k? then key = argv.k
else if argv.key? then key = argv.key
else throw new Error 'Missing `--key` argument.'
key = fs.readFileSync key
port = 8000
if argv.p? then port = argv.p
if argv.port? then port = argv.port
Server = require '../src/Server'
winston = require 'winston' # todo: consider using `bunyan`
server = Object.create Server
server.init cert, key, port, winston
server.listen () ->
winston.info "Server listening on #{port}."