-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (39 loc) · 1.36 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import express from "express";
import path from "path";
import __dirname from "./dirname.js";
import cookieParser from "cookie-parser";
import cors from "cors";
import logger from "morgan";
import usersRouter from "./routes/users.js";
import donationRouter from "./routes/donation.js";
import shoppinglistRouter from "./routes/shoppinglists.js";
import pantryListRouter from "./routes/pantryList.js";
import produceRouter from "./routes/produceData.js";
import mealPlanRouter from "./routes/mealplan.js";
import apiRouter from "./routes/edamam.js"
import donationbank from "./routes/donationbank.js";
const app = express();
app.use(logger("dev"));
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "public")));
app.use("/users", usersRouter);
app.use("/donations", donationRouter);
app.use("/shoppinglists", shoppinglistRouter);
app.use("/pantryList", pantryListRouter);
app.use("/produce", produceRouter);
app.use("/mealplan", mealPlanRouter);
app.use("/api", apiRouter);
app.use("/donationbank", donationbank);
app.use(function (req, res, next) {
res
.status(404)
.json({ message: "We couldn't find what you were looking for 😞" });
});
app.use(function (err, req, res, next) {
console.error(err.stack);
res.status(500).json(err);
});
export default app;