-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (30 loc) · 1016 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
28
29
30
31
32
33
const express = require('express')
const app = express();
const cookieParser = require('cookie-parser')
const path = require('path')
const db = require('./config/mongoose-connection')
const ownerRouter = require('./routes/ownerRouter')
const productRouter = require('./routes/productRouter')
const userRouter = require('./routes/userRouter')
const index = require('./routes/index')
const expressSession = require('express-session')
const flash = require('connect-flash')
require('dotenv').config();
app.use(express.json())
app.use(express.urlencoded({extended:true}))
app.use(cookieParser())
app.use(expressSession({
resave: false,
saveUninitialized: false,
secret: process.env.EXPRESS_SESSION_SECRET,
}))
app.use(flash())
app.use(express.static(path.join(__dirname, 'public')))
app.set('view engine','ejs')
app.use('/',index)
app.use('/owners',ownerRouter)
app.use('/users',userRouter)
app.use('/products',productRouter)
app.listen(3000, () => {
console.log('Server is running on port 3000');
});