-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (22 loc) · 728 Bytes
/
server.js
File metadata and controls
30 lines (22 loc) · 728 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
29
30
import express from "express";
import dotenv from "dotenv"
import mongoose from "mongoose";
import cookieParser from "cookie-parser";
import authRouter from "./routes/authRoutes.js";
import profileRoutes from "./routes/profileRoutes.js"
dotenv.config()
const app = express()
app.use(express.json());
app.use(cookieParser());
const PORT = process.env.PORT
mongoose.connect(process.env.MONGO_URI)
.then(()=> console.log("Connected to mondo DB"))
.catch((err)=> console.error("Mongo connection error:",err))
app.use("/api/profile",profileRoutes);
app.get("/",(req,res) =>{
res.send("Server is ready")
})
app.use("/api/auth",authRouter);
app.listen(PORT, () =>{
console.log(`Server is running at ${PORT}`)
})