-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
88 lines (56 loc) · 1.86 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// 1. dependencies declaration section
require('dotenv').config()
const express =require('express')
const app = express()
const path = require('node:path')
const morgan = require('morgan')
const session = require('express-session')
const passport = require('passport')
// const { request } = require('http')
const PORT = process.env.PORT || 3000
// const data = require('./data/data')
const methodOverride = require('method-override');
const routes = require('./routes/index-routes')
// 2. Set statement for ejs
app.set('view engine', 'ejs')
// 3. Use statements for public folder and morgan
app.use(express.static(path.join(__dirname, 'public')))
// app.use(morgan('combined'))
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(methodOverride('_method'))
app.use(morgan('dev'));
app.use(session({
secret: process.env.SECRET_KEY,
resave: false,
saveUninitialized: false
}))
app.use(passport.initialize())
app.use(passport.session())
app.use(routes);
// 4. Routes setup
// app.get('/', (request,response) => {
// response.render('pages/index')
// response.send("This route points to the Home page")
// })
// app.get('/about', (request,response) => {
// response.render('pages/about')
// response.send("This route points to the About page")
// })
// app.get('/login', (request,response) => {
// response.render('pages/login')
// response.send("This route points to the Login page")
// })
// app.get('/admin', (request,response) => {
// response.render('pages/admin')
// response.send("This route points to the Admin page")
// })
// app.get('/map', (request,response) => {
// response.render('pages/map')
// response.send("This route points to the Map page")
// })
require('./config/connection')
// 5. Server setup
app.listen(PORT, () => {
console.log(`server is listening on ${PORT}`)
})