forked from praseetha-sadaindia/OATH2-googleDrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·40 lines (32 loc) · 949 Bytes
/
index.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
const express = require('express')
const homeRouter = require('./routes/home')
const authRouter = require('./routes/auth')
const passportConfig = require('./configs/passport')
const passport = require('passport')
const cookieSession = require('cookie-session')
const KEYS = require('./configs/keys')
const nunjucks = require('nunjucks')
const fileUpload = require('express-fileupload')
// init app
let app = express()
const port = 3000 || process.env.PORT
app.listen(port, () => console.log(`server is running on ${port}`))
// init view
nunjucks.configure('views', {
autoescape: true,
express: app
});
// init static
app.use('/static', express.static('public'))
// init session
app.use(cookieSession({
keys: [KEYS.session_key]
}))
// init passport
app.use(passport.initialize())
app.use(passport.session())
// file upload
app.use(fileUpload());
// init routes
app.use('', homeRouter) // home
app.use('/auth', authRouter) // auth