-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
48 lines (35 loc) · 1.14 KB
/
app.js
File metadata and controls
48 lines (35 loc) · 1.14 KB
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
// 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");
const cors = require("cors");
// Creating an express application
const app = express();
// Importing the routes for users and todos
const userRouter = require("./routes/user.route");
const todosRouter = require("./routes/todos.route");
const adminRouter = require("./routes/admin.route");
app.use(
cors({
origin: "https://main--taskifysmart.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"));
// Adding the notification job
require("./jobs/NotificationJob");
// 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/todos", todosRouter);
app.use("/api/v1/admin", adminRouter);
// Export the express app
module.exports = app;