forked from ALPHACamp/simple-twitter-express-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
27 lines (19 loc) · 795 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
26
27
const express = require('express')
const bodyParser = require('body-parser')
if (process.env.NODE_ENV !== 'production') { require('dotenv').config() }
const helpers = require('./_helpers');
const passport = require('./config/passport')
const cors = require('cors')
const app = express()
const port = process.env.PORT || 3000
// cors 的預設為全開放
app.use(cors())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
// setting upload-images dir
app.use('/upload', express.static(__dirname + '/upload'))
// use helpers.getUser(req) to replace req.user
// use helpers.ensureAuthenticated(req) to replace req.isAuthenticated()
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
require('./routes/index')(app)
module.exports = app