-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
52 lines (44 loc) · 1.49 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
require('dotenv').config();
const fs = require('fs')
const path = require('path')
const bodyParser = require('body-parser');
const express = require('express');
const session = require('express-session')
const app = express();
const auth = require('./config/auth')
require('./config/connection')
app.set("view engine" , 'ejs');
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true,
cookie: { secure: false , maxAge : 60 * 60 * 24 * 6000}
}))
app.use(bodyParser.urlencoded({extended : false}))
app.use(express.static('public'))
// Requiring Routes
const indexRoute = require('./routes/indexRoute')
const loginRoute = require('./routes/loginRoute')
const registerRoute = require('./routes/registerRoute')
const profileRoute = require('./routes/profileRoute')
const sellRoute = require('./routes/sellRoute')
const productRoute = require('./routes/productRoute')
const myadsRoute = require('./routes/myadsRoute')
const notificationRoute = require('./routes/notificationRoute')
// Using Routes
app.use('/' ,indexRoute)
app.use('/login' , loginRoute)
app.use('/register' , registerRoute)
app.use('/profile' , auth , profileRoute)
app.use('/sell' , auth , sellRoute)
app.use('/product' , auth , productRoute)
app.use('/myads' , auth , myadsRoute)
app.use('/notification' , auth , notificationRoute)
// Listening app
app.listen(process.env.PORT , (err)=>{
if(err){
console.log(err);
}else{
console.log("Server started at " + process.env.PORT);
}
})