flame/server.js

33 lines
973 B
JavaScript
Raw Normal View History

require('dotenv').config();
const http = require('http');
const { connectDB } = require('./db');
const api = require('./api');
const jobs = require('./utils/jobs');
const Socket = require('./Socket');
const Sockets = require('./Sockets');
2021-05-22 20:04:34 +03:00
const associateModels = require('./models/associateModels');
const initConfig = require('./utils/initConfig');
const findCss = require('./utils/findCss');
2021-06-22 15:49:00 +03:00
const Logger = require('./utils/Logger');
const logger = new Logger();
2021-05-06 20:03:31 +03:00
const PORT = process.env.PORT || 5005;
(async () => {
await connectDB();
await associateModels();
await initConfig();
findCss();
// Create server for Express API and WebSockets
const server = http.createServer();
server.on('request', api);
// Register weatherSocket
const weatherSocket = new Socket(server);
Sockets.registerSocket('weather', weatherSocket);
server.listen(PORT, () => {
2021-06-22 15:49:00 +03:00
logger.log(`Server is running on port ${PORT} in ${process.env.NODE_ENV} mode`);
})
})();