-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (30 loc) · 916 Bytes
/
server.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
const restify = require('restify')
const createCrashyServer = require('./lib/crashy')
const createRouterServer = require('./lib/custom-router')
const createSanitizeServer = require('./lib/custom-sanitize')
function main (cliArg) {
let server
if (cliArg === 'router') {
console.log('Using server with custom router')
server = createRouterServer(restify)
} else if (cliArg === 'sanitize') {
console.log('Using server with custom sanitizePath')
server = createSanitizeServer(restify)
} else {
console.log('Using crashy server')
server = createCrashyServer(restify)
}
server.get('/', (req, res, next) => {
res.set({
'Content-Type': 'text/plain',
'Content-Length': 5
})
res.send('hello')
return next()
})
server.listen(3000, err => {
if (err) throw err
console.log(`Listening on port ${server.address().port}`)
})
}
main(process.argv[2])