-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (32 loc) · 1009 Bytes
/
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
const express = require("express");
const app = express();
const cookieParser = require("cookie-parser");
const bodyParser = require("body-parser");
const fileUpload = require("express-fileupload");
const path = require("path");
const cors = require("cors");
const errorMiddleware = require("./middleware/error");
// Config
if (process.env.NODE_ENV !== "PRODUCTION") {
require("dotenv").config({ path: "config/config.env" });
}
app.use(express.json());
app.use(cookieParser());
app.use(bodyParser.urlencoded({extended: true}));
app.use(
cors({
origin: [process.env.FRONTEND_URL],
methods: ["GET", "POST", "PUT", "DELETE"],
credentials: true,
})
);
app.use(bodyParser.urlencoded({ extended: true }));
app.use(fileUpload());
// Route Imports
const user = require("./routes/userRoute");
const reminder = require("./routes/reminderRoute");
app.use("/api/v1/reminder", reminder);
app.use("/api/v1/users", user);
// Middleware for Errors
app.use(errorMiddleware);
module.exports = app;