-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (27 loc) · 870 Bytes
/
server.js
File metadata and controls
31 lines (27 loc) · 870 Bytes
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
// dependencies import statements
const express = require("express");
require("dotenv").config();
const cors = require("cors");
const helmet = require("helmet");
// Configuring Middlewares
const app = express();
app.use(cors());
app.use(helmet());
app.use(express.json());
// Other import statements of database and routes
const DBPool = require("./database/DBPool.js");
const initSchema = require("./database/initSchema.js");
initSchema(DBPool);
const mainRouter = require("./routes/mainRoute.js");
app.use("/api", mainRouter);
// Testing the Server
app.get("/api/test", (req, res) => {
res.status(200).json("Mediclined server is running just fine!!");
});
app.listen(process.env.PORT, (err) => {
if (err) {
console.log(`[ERROR]: Error in Starting Server !!`, err);
} else {
console.log(`[LOG]: Server Listening in Port ${process.env.PORT}`);
}
});