-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
38 lines (37 loc) · 1.1 KB
/
index.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
require('db/mongoose')
const express = require('express')
const app = express()
const signupRouter = require('router/signup')
const loginRouter = require('router/login')
const updateRouter = require('router/update')
const marketplaceRouter = require('router/marketplace')
const logoutRouter = require('router/logout')
const homeRouter = require('router/home')
const commentRouter = require('router/comments')
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
// const ejs = require('ejs')
app.set('view engine', 'ejs')
app.use(bodyParser.urlencoded({
extended: true
}))
app.use(express.json()) /*This is used to automatically parse json data */
app.use(cookieParser())
app.use(homeRouter)
app.use(signupRouter)
app.use(loginRouter)
app.use(logoutRouter)
app.use(updateRouter)
app.use(marketplaceRouter)
app.use(commentRouter)
app.use(express.static(__dirname + '/public'));
app.get('*',(req,res)=>{
res.send('404')
})
let port = process.env.PORT
if (port == null || port == ""){
port = 3000;
}
app.listen(port, () => {
console.log(`Server running on port ${port}`)
})