-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (37 loc) · 939 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
33
34
35
36
37
38
39
40
41
import nconf from 'nconf'
import * as path from 'node:path'
import createServer from './create-server.js'
nconf.env({ lowerCase: true })
nconf.argv()
nconf.file(path.join(__dirname, 'config.json'))
nconf.defaults({
// eslint-disable-next-line camelcase
rp_host: '::1',
// eslint-disable-next-line camelcase
rp_port: 14098,
// eslint-disable-next-line camelcase
is_fly: false,
})
nconf.required(['secret'])
console.log(`Settings: {
rp_host: ${nconf.get('rp_host')},
is_fly: ${nconf.get('is_fly')},
}`)
const server = createServer(
nconf.get('rp_host'),
Number(nconf.get('rp_port')),
nconf.get('secret'),
nconf.get('is_fly') === 'true',
)
setInterval(() => {
console.log(`${server.numRoutes} routes active`)
}, 5 * 60 * 1000)
server.bind().then(
() => {
console.log(`listening on ${server.host}:${server.port}`)
},
err => {
console.error('Error: ' + err + '\n' + err.stack)
process.exit(1)
},
)