-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
64 lines (49 loc) · 1.43 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import koa from 'koa';
//import session from 'koa-session';
import bodyParser from 'koa-bodyparser';
import auth from './middlewares/auth';
import Pug from 'koa-pug';
import mount from 'koa-mount';
import serve from 'koa-static';
// router
import Api from './Api/router';
import webRouter from './webRouter';
import config from './config';
let app = koa();
let CONFIG = {
key: 'leanlab', // [>* (string) cookie key (default is koa:sess) <]
maxAge: 86400000, //[>* (number) maxAge in ms (default is 1 days) <]
overwrite: true, //[>* (boolean) can overwrite or not (default true) <]
httpOnly: true, //[>* (boolean) httpOnly or not (default true) <]
signed: true, //[>* (boolean) signed or not (default true) <]
};
//yield var a;
app.keys = ['some secret hurr']
//app.use(session(CONFIG, app))
app.use(function* (next){
this.locals = {};
this.request.session = {};
yield next;
});
const pug = new Pug({
viewPath: './views',
debug: false,
noCache: true,
pretty: false,
compileDebug: false,
locals: {
static_url: config.static_url
}, //global_locals_for_all_pages,
basedir: './views/',
helperPath: [
{ _: require('underscore') }
],
app: app
});
app.use(mount('/static', serve('dist')));
//app.use(mount('/assets/avatar', serve('assets/avatar')));
app.use(auth.authUser);
app.use(bodyParser());
app.use(Api.routes());
app.use(webRouter.routes());
app.listen(3000);