-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (26 loc) · 800 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
34
const express = require('express')
require('dotenv').config()
const {adminRoute,frontendRoute} = require('./routes')
const expressEjsLayouts = require('express-ejs-layouts')
const dbConnect = require('./database/dbConnect')
const PORT = process.env.PORT || 9012
const app = express()
app.use(express.static(__dirname+'/public'))
app.set('view engine','ejs')
app.use(express.urlencoded({extended:false}))
app.use(express.json())
app.use('/',frontendRoute )
app.use(expressEjsLayouts)
app.set('layout','pages/admin/layouts/master')
app.use('/admin',adminRoute)
const startServer=async()=>{
try {
await dbConnect.authenticate()
app.listen(PORT,()=>{
console.log(`App is running on {http://localhost:${PORT}}`);
})
} catch (error) {
console.log(Error);
}
}
startServer()