This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
node-fftcg/server.coffee
2018-12-27 13:03:58 +01:00

40 lines
908 B
CoffeeScript

# node libraries
bodyParser = (require 'body-parser')
express = (require 'express')
sharedSession = (require 'express-socket.io-session')
helmet = (require 'helmet')
http = (require 'http')
path = (require 'path')
# my libraries
FFTCGSOCKET = (require './inc/socket')
FFTCGSESSION = (require './inc/session')
FFTCGROUTER = (require './inc/router')
FFTCGLOG = new (require './inc/console')('FFTCG')
# express framework
app = express()
app.use helmet()
app.use bodyParser.urlencoded
extended: true
# sessions
sessionMiddleware = FFTCGSESSION(app)
app.use sessionMiddleware
# routes
app.use FFTCGROUTER
# socket.io
web = http.Server app
socket = new FFTCGSOCKET web, sharedSession sessionMiddleware
# Create server
web.listen 3000, ->
FFTCGLOG.log 'Listening on port 3000 ...'
# Handle termination
process.on 'SIGINT', ->
socket.close()
FFTCGLOG.log 'shutting down after SIGINT'
process.exit()