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

33 lines
757 B
CoffeeScript

# node libraries
express = (require 'express')
helmet = (require 'helmet')
http = (require 'http')
path = (require 'path')
# my libraries
FFTCGSOCKET = (require './inc/socket')
# express + socket framework
app = express()
web = http.Server app
socket = new FFTCGSOCKET(web, path.resolve(__dirname, 'fftcg.db'))
app.use helmet()
# Static content
app.use express.static path.resolve(__dirname, 'public_html')
# Templates
app.set 'view engine', 'pug'
app.get '/:template.html', (req, res) ->
res.render (req.params.template + '.pug')
# Create server
web.listen 3000, ->
console.log '[FFTCG] Listening on port 3000 ...'
# Handle termination
process.on 'SIGINT', ->
socket.close()
console.log '[FFTCG] shutting down after SIGINT'
process.exit()