-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.coffee
38 lines (35 loc) · 1.03 KB
/
server.coffee
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
whakaruru = require 'whakaruru/verbose'
whakaruru ->
express = require 'express'
app = express()
mutunga = require 'http-mutunga'
httpServer = mutunga app
compression = require 'compression'
app.use compression()
bodyParser = require 'body-parser'
app.use bodyParser.urlencoded
limit: '50mb'
extended: yes
app.use bodyParser.json
limit: '50mb'
app.set 'json spaces', 2
pods = [
require './server/auth'
require './server/static'
require './server/query'
require './book/server'
require './server/root'
]
pod app, httpServer for pod in pods
pjson = require './package.json'
port = 8080
httpServer.listen port, ->
host = httpServer.address().address
boundport = httpServer.address().port
shutdown = ->
console.log "#{pjson.name}@#{pjson.version} ōhākī waiting for requests to finish"
httpServer.close ->
console.log "#{pjson.name}@#{pjson.version} e noho rā!"
process.exit 0
process.on 'SIGTERM', shutdown
process.on 'SIGINT', shutdown