-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (27 loc) · 1003 Bytes
/
index.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
36
37
38
39
40
require("dotenv").config();
require("./db");
const cors = require("cors");
const express = require("express");
const { cardImagesRouter } = require("./routes/cardImages");
const { newCardRouter } = require("./routes/newCards");
const { matchesRouter } = require("./routes/matches");
const { questionImagesRouter } = require("./routes/reflectQuestions");
const { errorHandler } = require("./middelwares/errorHandler");
const app = express();
const port = process.env.PORT || 5001;
app.use(express.json());
app.use(cors({ origin: "*" }));
app.use("/cardimages", cardImagesRouter);
app.use("/newcard", newCardRouter);
app.use("/matches", matchesRouter);
app.use("/questions", questionImagesRouter);
app.get("/", (req, res) => {
res.send("Welcome to the Online Game for the Feminist Tech Card Deck");
});
app.use("/error", (req, res, next) => {
next(new Error("this is the error message"));
});
app.use(errorHandler);
app.listen(port, () => {
console.log(`http://localhost:${port}`);
});