-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (37 loc) · 1.26 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
// Importing the express library
const express = require("express");
// Importing the morgan library to log requests
const morgan = require("morgan");
// Importing the cookie parser library
const cookieParser = require("cookie-parser");
// Importing the cors library
const cors = require("cors");
// Router Imports
const userRouter = require("./routes/user.route");
const categoryRouter = require("./routes/category.route");
const ticketRouter = require("./routes/ticket.route");
const commentRouter = require("./routes/comment.route");
const adminRouter = require("./routes/admin.route");
// Creating an express application
const app = express();
app.use(
cors({
origin: "https://quick-fix-tickets.netlify.app",
credentials: true,
})
);
// parse the cookies of the request
app.use(cookieParser());
// Adding middleware to parse the request body
app.use(express.json());
// to log requests
app.use(morgan("dev"));
// Serving static files from the 'uploads' directory
app.use("/uploads", express.static("uploads"));
// Creating routes
app.use("/api/v1/users", userRouter);
app.use("/api/v1/categories", categoryRouter);
app.use("/api/v1/tickets", ticketRouter);
app.use("/api/v1/comments", commentRouter);
app.use("/api/v1/admin", adminRouter);
module.exports = app;