-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·38 lines (30 loc) · 966 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
37
38
var express = require('express')
var session = require('express-session')
var passport = require('passport')
var mongoose = require('mongoose')
var path = require('path')
var routes = require('./app/routes/index')
require('dotenv').config()
var app = express()
// Require dotenv and apply config to use env variables
mongoose.connect(process.env.MONGO_URI)
mongoose.Promise = global.Promise
require('./app/config/passport')(passport)
// Set middleware
app.use(express.static('./static'))
app.use(session({
secret: 'cloneterest',
saveUninitialized: true,
resave: true
}))
app.use(passport.initialize())
app.use(passport.session())
// Set view engine
app.set('view engine', 'ejs')
// Set location of views
app.set('views', path.join(__dirname, 'app/views'))
routes(app, passport)
// Port to listen to
// Change to process.env.PORT while deploying to heroku
app.listen(process.env.PORT||3000)
console.log('Server running on port 3000 http://localhost:3000');