-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (29 loc) · 941 Bytes
/
index.js
File metadata and controls
38 lines (29 loc) · 941 Bytes
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 ('dotenv').config()
const express = require('express')
const dbConnection = require('./utils/dbConnection')
const errorHandler = require('./middlewares/errorHandler')
const applyRoutes = require('./routes/routes')
const applyMiddleware = require('./middlewares/middlewares')
const sheduleTask = require('./utils/sheduleTask')
const app = express()
const path = require('path')
//serve client side file path
app.use(express.static(path.join(__dirname,'public')))
app.use(express.static(path.join(__dirname, './client/dist')));
//all middleware apply
applyMiddleware(app)
//database configuration
dbConnection()
//all routes enable
applyRoutes(app)
app.get('*',(req,res)=>{
res.sendFile(path.join(__dirname, './client/dist/index.html'))
})
//task
sheduleTask()
//errorHandling Configuration
errorHandler(app)
const port = process.env.PORT || 8080
app.listen(port,()=>{
console.log('Server listening on port '+ port)
})