Spaces:
Running
Running
File size: 1,008 Bytes
e4f1db2 b4331db e4f1db2 |
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 |
const express = require('express');
const cors = require('cors');
const path = require('path');
require('dotenv').config();
const app = express();
const PORT = process.env.PORT || 3001;
app.use(cors());
app.use(express.json());
const algorithmsRoute = require('./routes/algorithms');
const pubmedRoute = require('./routes/pubmed');
const searchRoute = require('./routes/search');
app.use('/api/algorithms', algorithmsRoute);
app.use('/api/pubmed', pubmedRoute);
app.use('/api/search', searchRoute);
app.get('/api/health', (req, res) => {
res.json({ status: 'OK', message: 'PubMed AI Explorer API is running' });
});
// Serve static files from the React app build directory
app.use(express.static(path.join(__dirname, '../frontend/dist')));
// Catch all handler: send back React's index.html file for any non-API routes
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, '../frontend/dist/index.html'));
});
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
}); |