-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (35 loc) · 1.1 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
if (process.env.NODE_ENV === 'development') {
require('dotenv').config()
}
const express = require('express')
const flash = require('connect-flash')
const session = require('express-session')
const app = express()
const port = 3000
const { engine } = require('express-handlebars')
const methodOverride = require('method-override')
const passport = require('./config/passport')
const messageHandler = require('./middlewares/message-handler')
const errorHandler = require('./middlewares/error-handler')
const routes = require('./routes')
app.engine('.hbs', engine({ extname: '.hbs' }))
app.set('view engine', '.hbs')
app.set('views', './views')
app.use(express.static('public'))
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use(methodOverride('_method'))
app.use(session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false
}))
app.use(flash())
app.use(passport.initialize())
app.use(passport.session())
app.use(messageHandler)
app.use(routes)
app.use(errorHandler)
app.listen(port, () => {
console.log(`express server is running HTTP://localhost:${port}`)
})