# node libraries
logger = (require 'logging').default 'FFTCG'
fastify = (require 'fastify') logger: logger
path = (require 'path')
# my libraries
socket = (require './socket')
# FFTCGSESSION = (require './session')
routes = (require './routes')
# fastify framework
fastify.register (require 'fastify-cookie')
fastify.register (require 'fastify-ws'), library: 'uws'
fastify.register (require 'fastify-static'), root: path.join __dirname, 'tmpfront'
fastify.ready()
.then ->
fastify.ws.on 'connection', socket
.catch (err) ->
logger.error err
process.exit 1
for route in routes
fastify.route route
fastify.listen 3001, '0.0.0.0'
# Handle termination
process.on 'SIGINT', ->
socket.close()
logger.info 'shutting down after SIGINT'
process.exit()