-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
40 lines (35 loc) · 871 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
import express from "express";
import userRoute from "./Routes/user.js";
import { config } from "dotenv";
import cookieParser from "cookie-parser";
import taskRouter from "./Routes/task.js";
import { errorMiddleWare } from "./middlewares/error.js";
import cors from "cors";
const app = express();
//configuration
config({
path: "./config/config.env",
});
//middleware
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(
cors({
origin: [process.env.FRONTEND_URL],
methods: ["GET", "POST", "PUT", "DELETE"],
credentials: true,
})
);
//routes
app.get("/", (req, res) => {
res.status(200).json({
success: true,
message: `welcome to web service api`,
});
});
app.use("/user", userRoute);
app.use("/task", taskRouter);
// @error middleware
app.use(errorMiddleWare);
export default app;