-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
33 lines (26 loc) · 961 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
32
33
const AppRouter = require("./routes/AppRouter");
const PORT = process.env.PORT || 3001;
const express = require("express");
const app = express();
const path = require("path");
// Require Middleware
const logger = require("morgan");
const bodyParser = require("body-parser");
const cors = require("cors");
const helmet = require("helmet");
// Require Middleware
// Initialize Middleware
app.use(logger("dev"));
app.use(helmet({ contentSecurityPolicy: false }));
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, "client", "build")));
// Initialize Middleware
app.disable("X-Powered-By");
app.get("/", (req, res) => res.send({ msg: "Petsagram Server Working" }));
app.use("/api", AppRouter);
app.get("*", (req, res) =>
res.sendFile(path.join(__dirname, "client", "build", "index.html"))
);
app.listen(PORT, () => console.log(`Server Started On Port: ${PORT}`));