-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
35 lines (29 loc) · 1.06 KB
/
server.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
const http = require('http');
require('colors');
const database = require('./src/config');
const createApp = require('./src/app');
/**
* Main entry point for the application.
*
* @param {Object} database - The database configuration object.
* @param {Function} createApp - A function that creates and configures the Express application.
* @throws {Error} If there's an issue starting the application.
*/
const startApp = async (database, createApp) => {
const { NODE_ENV: MODE, PORT = 3000 } = process.env;
// Create the Express application
const app = await createApp(database);
// Start the server
const server = http.createServer(app).listen(PORT, () => {
console.log(
'App is running in '.brightMagenta.underline.bold.italic +
MODE.brightYellow.underline.bold.italic +
' mode on port '.brightMagenta.underline.bold.italic +
PORT.brightYellow.underline.bold.italic +
' 🚀...'.brightMagenta.underline.bold.italic
);
return server;
});
};
// Start the application
module.exports = startApp(database, createApp);