Docker build. Catch client routes on server. Initial config utility

This commit is contained in:
unknown 2021-06-07 13:40:51 +02:00
parent d2e6ebae4f
commit 1636b705de
10 changed files with 125 additions and 13 deletions

View file

@ -1,3 +1,4 @@
require('dotenv').config();
const http = require('http');
const { connectDB } = require('./db');
const api = require('./api');
@ -5,12 +6,15 @@ const jobs = require('./utils/jobs');
const Socket = require('./Socket');
const Sockets = require('./Sockets');
const associateModels = require('./models/associateModels');
const initConfig = require('./utils/initConfig');
require('dotenv').config();
const PORT = process.env.PORT || 5005;
connectDB();
associateModels();
connectDB()
.then(() => {
associateModels();
initConfig();
});
// Create server for Express API and WebSockets
const server = http.createServer();
@ -21,5 +25,5 @@ const weatherSocket = new Socket(server);
Sockets.registerSocket('weather', weatherSocket);
server.listen(PORT, () => {
console.log(`Server is running on port ${PORT} in ${process.env.NODE_ENV} mode`.yellow.bold);
console.log(`Server is running on port ${PORT} in ${process.env.NODE_ENV} mode`);
})