/var/www/greso.tech/server/nsm
Edit: /var/www/greso.tech/server/nsm/index.js (1826B)
const config = require('./config/app.json')
const db = require('./models/index')
require('./errors/index')
require('./var')
const express = require('express')
const app = express()
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Headers", "Content-Type");
res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS");
next();
});
db.init()
.then(async () => {
const express = require('express')
const app = express()
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Headers", "Content-Type");
res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS");
next();
});
const router = express.Router()
const { createServer } = require('http')
const httpServer = createServer(app)
await RunServices({ db, config, httpServer })
require('./routes/index')({ app, db, router, config })
httpServer.listen(config.api.port || 3000, () => {
console.log(`Listen port ${config.api.port || 3000}`)
})
})
async function RunServices({ db, config, httpServer }) {
global.SERVICES = require('./services')({ db, config, httpServer })
await SERVICES.SystemService.Run()
await SERVICES.CompanyService.Run()
await SERVICES.RateAreaService.Run()
await SERVICES.AuthService.Run()
// await SERVICES.InventoryService.Run()
await SERVICES.LeadService.Run()
await SERVICES.MailService.Run()
await SERVICES.OrderService.Run()
}