server: fix sessions store not being in koa-session middleware

This commit is contained in:
Katalina / stardust 2017-12-27 00:51:14 -06:00
parent 6ec6123fa9
commit e36be9e381
3 changed files with 14 additions and 15 deletions

View file

@ -19,17 +19,12 @@ app.keys = [ process.env.APP_KEY ]
const DEVEL = process.env.NODE_ENV === 'development'
async function start () {
await M.awaitServices()
// body parser
const bodyParser = require('koa-bodyparser')
app.use(bodyParser({ types: ['json'] }))
const session = require('koa-session')
app.use(session({
key: 'roleypoly:sess',
maxAge: 'session',
store: M.sessions
}, app))
// Request logger
app.use(async (ctx, next) => {
let timeStart = new Date()
@ -52,11 +47,15 @@ async function start () {
return null
})
// Construct the Roleypoly!
const session = require('koa-session')
app.use(session({
key: 'roleypoly:sess',
maxAge: 'session',
store: M.ctx.sessions
}, app))
await M.mountRoutes()
// Start it!
await M.awaitServices()
log.info(`starting HTTP server on ${process.env.APP_PORT || 6769}`)
server.listen(process.env.APP_PORT || 6769)
}