-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
42 lines (34 loc) · 1.15 KB
/
server.js
File metadata and controls
42 lines (34 loc) · 1.15 KB
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
const express = require('express')
const path = require('path')
const app = express()
const PORT = process.env.PORT || 3000
// Import API routes
const runsRoutes = require('./api/routes/runs')
const dailyRoutes = require('./api/routes/daily')
// Middleware
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
// Health check endpoint
app.get('/health', (req, res) => {
res.status(200).json({
status: 'ok',
timestamp: new Date().toISOString(),
uptime: process.uptime(),
service: 'panodle-v2',
version: '2.0.0'
})
})
// API routes (must come before static files)
app.use('/api/runs', runsRoutes)
app.use('/api/daily', dailyRoutes)
// Serve static files from the React build directory
app.use(express.static(path.join(__dirname, 'build')))
// Handle React routing - return index.html for all other routes
app.use((req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'))
})
app.listen(PORT, '0.0.0.0', () => {
console.log(`Server is running on http://0.0.0.0:${PORT}`)
console.log(`Health check available at http://0.0.0.0:${PORT}/health`)
console.log(`API available at http://0.0.0.0:${PORT}/api`)
})