-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
35 lines (26 loc) · 978 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
require('dotenv').load()
const cookieParser = require('cookie-parser')
const express = require('express')
const passport = require('passport')
const TwitterStrategy = require('passport-twitter').Strategy
const auth = require('./lib/auth')
const users = require('./lib/users')
const apiRoutes = require('./routes/api')
process.on('unhandledRejection', (error, promise) => {
console.error('UNHANDLED REJECTION', error.stack)
})
const app = express()
app.set('JWT_SECRET', process.env.JWT_SECRET) // Can this be moved to api.js?
app.use(cookieParser())
app.use(passport.initialize()) // Can this be moved to api.js?
app.use('/api/v1', apiRoutes)
app.get('/', (req, res) => {
res.send(`Token is: ${req.cookies.token}`)
})
// Can these be moved to api.js?
passport.use(new TwitterStrategy(auth.twitterConfig, auth.verify))
passport.serializeUser(users.serialize)
passport.deserializeUser(users.deserialize)
app.listen(3000, () => {
console.log('Listening on 3000')
})