-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (28 loc) · 874 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
34
35
import express from "express";
import dotenv from "dotenv";
import userRoutes from "./Routes/user.routes.js";
import chatRoutes from "./Routes/chat.routes.js";
import messageRoutes from "./Routes/message.routes.js";
import uploadFile from "./Routes/upload.routes.js";
import { errorMiddleware } from "./middlewares/error.middleware.js";
import cors from "cors";
dotenv.config({
path: "./data/config.env",
});
const app = express();
app.use(express.json()); // enables the server to accept json req.body
app.use(cors());
app.get("/", (req, res) => {
res.status(200).send("Server running");
});
// user routes
app.use("/api/user", userRoutes);
// chat routes
app.use("/api/chat", chatRoutes);
// message routes
app.use("/api/message", messageRoutes);
// upload file
app.use("/api/upload", uploadFile);
// error handler
app.use(errorMiddleware);
export default app;