-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
52 lines (44 loc) · 1.6 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
51
52
const express = require('express')
const userRouter = require('./routers/user')
const settingsRouter = require('./routers/settingsTable')
const itemsMenuRouter = require('./routers/itemsMenu')
const warehouseRouter = require('./routers/warehouse')
const customersRouter = require('./routers/customers')
const categoryRouter = require('./routers/category')
const menuRouter = require('./routers/menu')
const customerLIst = require('./routers/customerList')
const path = require('path')
require('dotenv').config({ path: __dirname + '/.env' })
process.env.NODE_TLS_REJECT_UNAUTHORIZED = undefined
process.env.NODE_TLS_REJECT_UNAUTHORIZED || 0
const socketRouter = require('./routers/socket')
const port = process.env.PORT || 8080
const app = express()
require('./db/db')
//CORS Middleware
app.use(function (req, res, next) {
//Enabling CORS
res.header('Access-Control-Allow-Origin', '*')
res.header('Access-Control-Allow-Credentials', true)
res.header('Access-Control-Allow-Methods', 'GET,HEAD,OPTIONS,POST,PUT,DELETE')
res.header('Access-Control-Allow-Headers', '*')
next()
})
app.use(express.json())
app.use(userRouter)
app.use(settingsRouter)
app.use(itemsMenuRouter)
app.use(warehouseRouter)
app.use(customersRouter)
app.use(categoryRouter)
app.use(menuRouter)
app.use(customerLIst)
//app.use(socketRouter)
// Serve only the static files form the dist directory
app.use(express.static(__dirname + '/dist/managerAppFrontend'))
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname + '/dist/managerAppFrontend/index.html'))
})
app.listen(port, () => {
console.log(`Server running on port ${port}`)
})