-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (21 loc) · 718 Bytes
/
server.js
File metadata and controls
28 lines (21 loc) · 718 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
const express = require("express");
const dotenv = require("dotenv");
const app = express();
const routers = require("./routers");
dotenv.config({ path: "./config/env/config.env" });
const PORT = process.env.PORT;
const connectDatabase = require("./helpers/database/connectDatabase");
const customErrorHandler = require("./middlewares/errors/customErrorHandler");
const path = require("path");
//* MongoDb Connection
connectDatabase();
app.use(express.json());
//* Routers Middleware
app.use("/api", routers);
//* Static files
app.use(express.static(path.join(__dirname, "public")));
//!Error Handler
app.use(customErrorHandler);
app.listen(PORT, () => {
console.log(`Server listening on port :${PORT}`);
});