-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
32 lines (27 loc) · 803 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const Koa = require('koa')
const views = require('koa-views')
const path = require('path')
const static = require('koa-static')
const convert = require('koa-convert')
const bodyParser = require('koa-bodyparser')
const app = new Koa()
const session = require('koa-session')
global.moment = require('moment')
app.keys = ['secret key']
let CONFIG = {
key: 'blog',
maxAge: 1000000,
overwrite: true,
httpOnly: true,
signed: true,
}
app.use(convert(session(CONFIG, app)))
app.use(convert(static(path.join(__dirname, 'public'))))
app.use(convert(static(path.join(__dirname, 'node_modules'))))
app.use(bodyParser())
app.use(views(path.join(__dirname, 'views/pages'), {
extension: 'pug'
}))
const router = require('./router/router')
app.use(router.routes()).use(router.allowedMethods())
app.listen(80)