-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
41 lines (34 loc) · 1.17 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
import express from 'express';
const cors = require('cors');
import researcherRoutes from './routes/researcherRoutes';
import assistantRoutes from './routes/assistantRoutes';
import postRoutes from './routes/postRoutes';
import applicationRoutes from './routes/applicationRoutes';
import accountRoutes from './routes/accountRoutes';
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'], // Replace with your front-end's domain
methods: 'GET,POST,PUT,DELETE', // Customize as needed
credentials: true // Enable this if you need to include cookies
}));
// Middleware to parse JSON bodies
app.use(express.json());
// Initial URL
app.get('/', (req, res) => {
res.send('Things are working :)');
});
// Use route files
app.use('', researcherRoutes);
app.use('', assistantRoutes);
app.use('', postRoutes);
app.use('', accountRoutes);
app.use('', searchRoutes);
app.use('', applicationRoutes);
// Start the server
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
export default app;