-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
29 lines (22 loc) · 885 Bytes
/
index.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
require("dotenv").config({ path: "./config/.env" });
require("./utils/index").logPrettifier();
const { globalErrorHandler } = require("./utils/index");
const config = require("./config/variables");
const app = require("express")();
const http = require('http');
const server = http.createServer(app);
require("./config/express")(app, config);
require("./config/app")(app);
require("./routes/router")(app);
app.use(globalErrorHandler);
server.listen(config.PORT, (err) => {
err
? console.error("Something went wrong with the server")
: new Promise((res, rej) => require("./config/db-connection")(config, res, rej))
.then(x => {
console.info(`DB connection established`);
console.info("Server is running.");
console.info("Open app on: \033[35mhttp://localhost:" + config.PORT);
})
.catch(console.error);
});