-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
39 lines (28 loc) · 692 Bytes
/
Copy pathapp.js
File metadata and controls
39 lines (28 loc) · 692 Bytes
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
import Koa from 'koa';
import bodyParser from 'koa-bodyparser';
import logger from 'koa-logger';
import serve from 'koa-static';
import session from 'koa-session';
import passport from 'koa-passport';
import router from './router';
const app = new Koa();
app.keys = ['timieSecret']
app.use(session({
key:'mySession'
}, app))
app.use(bodyParser());
app.use(logger());
app.use(serve('./src/view'))
require('./auth');
app.use(passport.initialize())
app.use(passport.session())
app.use(router.routes())
.use(router.allowedMethods());
app.use(function (ctx, next) {
if (ctx.isAuthenticated()) {
return next()
} else {
ctx.redirect('/login.html')
}
})
app.listen(3000);