-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (25 loc) · 704 Bytes
/
app.js
File metadata and controls
29 lines (25 loc) · 704 Bytes
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
import express from "express";
import userRouter from './routes/user.js';
import taskRouter from './routes/task.js';
import {config} from "dotenv"
import cookieParser from "cookie-parser";
import { errorMiddleware } from "./middleware/error.js";
import cors from "cors";
export const app = express();
config({
path:"./data/config.env",
});
// using middleware
app.use(express.json());
app.use(cookieParser());
app.use(cors({
origin:[process.env.FRONTEND_URL],
methods:["GET","POST","DELETE","PUT"],
credentials:true,
}));
app.use("/api/v1/users",userRouter);
app.use("/api/v1/task",taskRouter);
app.get("/",(req,res)=>{
res.send("Nice working bro");
});
app.use(errorMiddleware);