-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (29 loc) · 1.05 KB
/
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
34
35
const express = require("express");
const logger = require("morgan");
const favicon = require("serve-favicon");
const handleBefore = require("./middleware/beforeAndAfter");
require("dotenv").config();
const mongoRoutes = require("./routes/mongo.routes");
const authRoutes = require("./routes/auth.routes");
const cors = require("cors");
const app = express();
const port = process.env.PORT || 3000;
const corsOptions = {
credentials: true,
origin: ["https://react-kanban-board-main.netlify.app", "http://localhost:5173"],
};
app.use(cors(corsOptions))
app.use(logger("dev"));
app.use(express.static("public"));
app.use(express.json());
app.use(favicon("./public/favicon.ico"));
app.use(handleBefore);
app.use("/", authRoutes);
app.use("/mongo", mongoRoutes);
app.get("/hello", (_request, response) => {
response.send("<h1>Hello World</h1>");
});
app.get("*", (_request, response) => {
response.status(404).json({ message: "This route does not exist." });
});
app.listen(port, () => console.log("Express Server running on: http://localhost:" + port));