forked from ALPHACamp/twitter-api-2020
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
25 lines (22 loc) · 729 Bytes
/
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
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config()
}
const express = require('express')
const cors = require('cors')
const helpers = require('./_helpers')
const passport = require('./config/passport')
const routes = require('./routes')
const app = express()
const port = process.env.PORT || 3000
app.use(cors({ credentials: true, origin: true }))
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
app.use(passport.initialize())
app.use((req, res, next) => {
res.locals.user = helpers.getUser(req)
next()
})
app.use(routes)
app.get('/', (req, res) => res.send('..Hello World!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
module.exports = app