filo_caspar/api/koa.js

21 lines
456 B
JavaScript
Raw Normal View History

2016-04-10 08:37:05 +00:00
import serve from 'koa-static'
import Koa from 'koa'
import socket from 'koa-socket'
import config from '../config'
import log from '../log'
import router from './io/router'
import { bunyanLogger, errorHandler } from './middlewares'
const app = new Koa()
const io = new socket()
io.attach(app)
io.on('connection', router.bind(this, io))
app.use(bunyanLogger(log))
app.use(errorHandler())
app.use(serve('public'))
app.listen(config.get('server:port'))