-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathserver.js
37 lines (28 loc) · 1022 Bytes
/
server.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
const express = require('express')
const flash = require('connect-flash')
const hbs = require('express-handlebars')
const LocalStrategy = require('passport-local')
const FacebookStrategy = require('passport-facebook')
const passport = require('passport')
const path = require('path')
const auth = require('./lib/auth')
const users = require('./lib/users')
const session = require('./lib/session')
const apiRoutes = require('./routes/api')
const indexRoutes = require('./routes')
const app = express()
app.engine('hbs', hbs())
app.set('view engine', 'hbs')
app.set('views', path.join(__dirname, 'views'))
app.use(session)
app.use(flash())
app.use(express.static('public'))
app.use(passport.initialize())
app.use(passport.session())
app.use('/', indexRoutes)
app.use('/api/', apiRoutes)
passport.use(new LocalStrategy(auth.verify))
passport.use(new FacebookStrategy(auth.facebookOptions, auth.facebookVerify))
passport.serializeUser(users.serialize)
passport.deserializeUser(users.deserialize)
module.exports = app