-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (27 loc) · 767 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
import express from "express";
export const app = 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 "./middlewares/error.js";
import cors from 'cors';
config({
path:"./data/config.env"
})
app.use(cors({
origin: [process.env.FRONTEND_URL],
methods:["GET","POST","PATCH","DELETE"],
credentials: true,
}))
//using Middlewares
app.use(express.json());
app.use(cookieParser());
app.use(express.urlencoded({extended:true}))
//using routes
app.use('/api/v1/users',userRouter)
app.use('/api/v1/task',taskRouter)
app.get("/",(req,res)=>{
res.send("hello mother fucker!!")
})
app.use(errorMiddleware)