-
Notifications
You must be signed in to change notification settings - Fork 45
/
cli.js
executable file
·33 lines (26 loc) · 848 Bytes
/
cli.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
#!/usr/bin/env node
'use strict'
const program = require('commander')
const { Server } = require('.')
const { version } = require('./package')
module.exports = async (argv) => {
program
.version(version, '-v, --version')
.option('-p, --port [port]', 'web server port', 3000)
.option('-d, --domain [domain]', 'public web server domain', 'hypertunnel.lvh.me')
.option('-t, --token [token]', 'token required to be sent by clients', 'free-server-please-be-nice')
.parse(argv)
const server = new Server({
serverPort: program.port,
serverDomain: program.domain,
serverToken: program.token
})
await server.create()
process.on('uncaughtException', (err) => {
console.error(err)
})
process.on('unhandledRejection', (reason, promise) => {
console.error(reason)
})
}
module.exports(process.argv)