-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
30 lines (25 loc) · 934 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
const cors = require("cors");
const express = require("express");
const verifyToken = require("./verifyToken");
const userRoutes = require("./routes/userRoutes");
const googleRoutes = require("./routes/googleRoutes");
const favouritesRoutes = require("./routes/favouritesRoutes");
const historyRoutes = require("./routes/historyRoutes");
const mapQuestRoutes = require("./routes/mapQuestRoutes");
require("./db");
require("dotenv").config();
const app = express();
app.use(cors());
app.use(express.json());
const port = process.env.PORT || 4000;
app.listen(port, () => {
console.log(`listening on port: ${port}`);
});
app.get("/protected", verifyToken, (req, res) => {
res.json({ message: "This route is protected.", userId: req.userId });
});
app.use("/user", userRoutes);
app.use("/google", googleRoutes);
app.use("/favourites", favouritesRoutes);
app.use("/history", historyRoutes);
app.use("/map-quest", mapQuestRoutes);