forked from pranavpandey1998official/serverSEN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
29 lines (21 loc) · 713 Bytes
/
app.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
const express = require("express");
const helmet = require("helmet");
const cors = require("cors");
const bodyParser = require("body-parser")
require("dotenv").config();
const app = express();
const port = 5000 || process.env.PORT;
const auth = require("./routers/auth");
app.use(helmet()); // Sanitization of requests
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json()); // Parsing requests as in JSON format
app.use(cors()); //Use CORS
app.use("/auth", auth);
// Error handling
app.use((req, res) => {
return res.status(500).json({ message: "Server Error, Something Broke" });
});
// Start Server
app.listen(port, () => console.log("Server running on port", port, "..."));