-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
62 lines (50 loc) · 1.73 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require('dotenv').config()
const express = require('express');
const session = require('express-session');
const passport = require('passport');
const passportInit = require('./utils/passportConfig.js')
const bodyParser = require('body-parser')
const flash = require('express-flash')
const mongoose = require('mongoose');
const landingRouter = require('./routes/landingRouter.js'),
loginRouter = require('./routes/loginRouter.js'),
regRouter = require('./routes/regRouter.js'),
passRouter = require('./routes/passRouter.js'),
cityRouter = require('./routes/cityRouter.js'),
helpRouter = require('./routes/helpRouter.js'),
solutionRouter = require('./routes/solutionRouter.js')
const app = express();
app.set('view engine', 'ejs')
app.use(bodyParser.urlencoded({
extended: true
}));
const dbUri = process.env.MONGO_URI
mongoose.connect(process.env.MONGO_URI, console.log('MONGODB CONNECTED'))
app.use('/',express.static(__dirname));
app.use(express.static('public'))
app.use('/', express.static('public'))
app.use(express.static('uploads'))
app.use('/', express.static('uploads'))
app.set('view engine', 'ejs')
app.use(flash())
app.use(session({
secret: process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true
}))
app.use(express.urlencoded({extended: false}))
app.use(express.json({limit: '1mb'}))
app.use(passport.initialize())
app.use(passport.session())
passportInit(passport)
app.use('/', landingRouter)
app.use('/login', loginRouter)
app.use('/register', regRouter)
app.use('/pass', passRouter)
app.use('/city', cityRouter)
app.use('/help', helpRouter)
app.use('/solution', solutionRouter)
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server started on port ${PORT}`)
});