-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
42 lines (34 loc) · 1.12 KB
/
index.ts
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, { Request, Response } from "express";
import cors from "cors";
import researcherRoutes from "./routes/researcherRoutes";
import assistantRoutes from "./routes/assistantRoutes";
import postRoutes from "./routes/postRoutes";
import applicationRoutes from "./routes/applicationRoutes";
import searchRoutes from "./routes/searchRoutes";
const app = express();
const port = process.env.PORT || 3000;
// Enable CORS for all routes
app.use(
cors({
origin: ["https://research-finder-1000.web.app", "http://localhost:5173"],
methods: ["GET", "POST", "PUT", "DELETE"],
credentials: true,
})
);
// Middleware to parse JSON bodies
app.use(express.json());
// Initial URL
app.get("/", (req: Request, res: Response) => {
res.send("Things are working :)");
});
// Use route files with proper prefixes
app.use("/researchers", researcherRoutes);
app.use("/assistants", assistantRoutes);
app.use("/posts", postRoutes);
app.use("/search", searchRoutes);
app.use("/applications", applicationRoutes);
// Start the server
app.listen(port, () => {
console.log(`🚀 Server is running on port ${port}`);
});
export default app;