2018-06-25 10:07:10 +00:00
|
|
|
const config = require('./config')
|
|
|
|
const Koa = require('koa')
|
|
|
|
const koaLogger = require('koa-logger')
|
2018-08-12 15:31:09 +00:00
|
|
|
const koaSession = require('koa-session2')
|
2018-06-25 10:07:10 +00:00
|
|
|
const router = require('./route')
|
|
|
|
const app = new Koa()
|
|
|
|
|
|
|
|
app.use(koaLogger())
|
2018-08-12 15:31:09 +00:00
|
|
|
app.use(koaSession())
|
2018-06-25 10:07:10 +00:00
|
|
|
app.use(router.allowedMethods())
|
|
|
|
app.use(router.routes())
|
|
|
|
|
|
|
|
const server = app.listen(config.port, () => {
|
|
|
|
console.log(`server start on port ${server.address().port}`)
|
|
|
|
})
|
|
|
|
|
|
|
|
module.exports = server
|