-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
31 lines (25 loc) · 879 Bytes
/
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
const express = require("express");
const app = express();
const bodyParser = require("body-parser");
const dotenv = require("dotenv");
const colors = require("colors");
const connectDB = require("./config/db");
dotenv.config({ path: "./config/config.env" });
connectDB();
var registration = require("./routes/registration");
app.set("view engine", "ejs");
app.use(express.static("js"));
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use("/registration", registration);
const server = app.listen(process.env.PORT || 3000, () => {
console.log(
`Server running in ${process.env.NODE_ENV} mode on port ${process.env.PORT}`
.yellow.bold
);
});
//Handle unhandled Rejections
process.on("unhandledRejection", (err, promise) => {
console.log(`Unhandled Rejection: ${err.message}`.red);
server.close(() => process.exit(1));
});