-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (27 loc) · 780 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";
import userrouter from './routes/user.js'
import { connectdb } from "./data/database.js";
import taskRouter from "./routes/tasks.js"
import {config} from 'dotenv'
import cookieParser from "cookie-parser";
import cors from "cors";
config({
path:"./data/config.env"
});
connectdb();
const app = express();
app.use(express.json())
app.use(cookieParser())
app.use(cors({
origin:[process.env.FRONTEND_URL],
methods:["GET","POST","PUT","DELETE"],
credentials:true,
}))
app.use("/api/v1/users",userrouter)
app.use("/api/v1/task",taskRouter)
app.get("/",(req,res)=>{
res.send("nice working")
})
app.listen(process.env.PORT,()=>{
console.log(`server is working on port ${process.env.PORT} in ${process.env.NODE_ENV} mode`)
})