File size: 705 Bytes
1ee4c18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
const express = require('express');
const cors = require('cors');
const dotenv = require('dotenv');
const path = require('path');
const roastRoutes = require('./routes/roast');

dotenv.config();

const app = express();
const PORT = process.env.PORT || 3007;

app.use(cors());
app.use(express.json({ limit: '1mb' }));

app.use('/api/roast', roastRoutes);

app.get('/api/health', (req, res) => {
  res.json({ status: 'ok', service: 'code-roast-battle' });
});

app.use(express.static(path.join(__dirname, 'public')));
app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, 'public', 'index.html'));
});

app.listen(PORT, () => {
  console.log(`Code Roast Battle API running on port ${PORT}`);
});