-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
44 lines (34 loc) · 996 Bytes
/
server.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
36
37
38
39
40
41
42
43
44
import express from "express";
import cors from "cors";
import { Server } from "socket.io";
import http from "http";
const PORT = process.env.PORT || 3000;
const app = express();
const httpServer = http.createServer(app);
app.use(cors({
origin: ["http://localhost:5173", "https://collaborative-doc.vercel.app"],
methods: ["GET", "POST", "PUT", "PATCH", "DELETE"],
credentials: true
}));
app.use(express.json());
app.use(express.urlencoded({extended: true}))
const io = new Server(httpServer, {
cors: {
origin: ["https://collaborative-doc.vercel.app", "http://localhost:5173"],
methods: ["GET", "POST", "PUT", "PATCH", "DELETE"],
},
});
app.get("/health-check", (req, res) => {
return res.status(200).json({ message: "ok" });
})
app.get("/", (req, res) => {
res.send("Hello World!");
})
import documentRoutes from "./routes/document.routes.js";
app.use("/api/v1/document", documentRoutes);
export {
app,
httpServer,
io,
PORT
}