-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (33 loc) · 925 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
30
31
32
33
34
35
36
37
38
39
40
41
42
// Reading dotenv file
import dotenv from "dotenv";
dotenv.config();
//importing dependencies
import express from "express";
import cookieParser from "cookie-parser";
import colors from "colors";
import logger from "./src/startup/logger.js";
import startup from "./src/startup/index.js";
import routes from "./src/routes/index.js";
import connectDB from "./src/startup/dbConnection.js";
import config from 'config';
//initializing express
const app = express();
// Call the Logger Function
logger(app);
// Call the Startup Function
startup(app);
// Call the Routes Function
routes(app);
// Connect to Database
connectDB();
// Cookie parsing
app.use(cookieParser());
//app port
const PORT = config.get('system.port') || 3000;
const NODE_ENV = config.get('system.node_env') || 'development';
const server = app.listen(
PORT,
console.log(
`Server running in ${NODE_ENV} mode on port ${PORT}`.yellow.bold
)
);