-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
42 lines (30 loc) · 1.29 KB
/
Copy pathserver.js
File metadata and controls
42 lines (30 loc) · 1.29 KB
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
41
42
import express from "express";
import "dotenv/config";
import cookieParser from "cookie-parser";
import { connectToMongoDB } from "./config/mongodb.config.js";
import authRoutes from "./routes/auth.routes.js"
import { isAuthenticated } from "./utils/isAuthenticated.js";
import userRoutes from "./routes/user.routes.js";
import { postRoutes } from "./routes/post.routes.js";
import { chatRoutes } from "./routes/chat.routes.js";
import { requestRoutes } from "./routes/request.routes.js";
import { notificationRoutes } from "./routes/notification.routes.js";
// import job from "./cron/cron.js";
const app = express();
// job.start();
app.use(express.json()); // to parse json data from req.body
app.use(express.urlencoded({extended:true})); // to parse form data from req.body
app.use(cookieParser());
app.get("/api/test",(req,res)=>{
res.send("test api to awake server");
})
app.use("/api/auth",authRoutes);
app.use("/api/user",isAuthenticated,userRoutes);
app.use("/api/post", isAuthenticated, postRoutes);
app.use("/api/chat",isAuthenticated,chatRoutes);
app.use("/api/request",isAuthenticated,requestRoutes);
app.use("/api/notification",isAuthenticated,notificationRoutes);
app.listen(process.env.PORT,()=>{
connectToMongoDB()
console.log(`server is live on port ${process.env.PORT}`);
})