-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
50 lines (40 loc) · 1.23 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
48
49
50
import express from "express";
import cors from "cors";
import bodyParser from "body-parser";
const jsonParser = bodyParser.json();
import symptomsRouter from "./routes/symptomsRouter.js";
import reminderRouter from "./routes/reminderRouter.js";
import petsRouter from "./routes/petsRouter.js";
import helmet from "helmet";
const app = express();
const PORT = process.env.PORT || 3000;
app.use(cors());
app.use(helmet());
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use("/symptoms", symptomsRouter);
app.use("/reminders", reminderRouter);
app.use("/pets", petsRouter);
app.get("/", function (req, res) {
res.json({
success: true,
message: "Test route is up and running!",
});
});
app.use(function (req, res, next) {
res
.status(404)
.json({ message: "We couldn't find what you were looking for 😞" });
});
// test route
app.use(express.json(cors, bodyParser));
app.use(function (err, req, res, next) {
console.error(err.stack);
res.status(500).json(err);
});
//this needs commenting out in order for tests to run correctly, fix this ina future sprint
app.listen(PORT, function () {
console.log(`Server is running on port ${PORT}`);
});
export default app;