#!/usr/bin/env node
const express = require('express');
const path = require('path');
const fs = require('fs');
const app = express();
const PORT = process.env.PORT || 8080;
// Serve static files from the public directory
app.use(express.static(path.join(__dirname, 'public')));
// Simple health check endpoint
app.get('/health', (req, res) => {
res.status(200).json({ status: 'ok' });
});
// Handle all other routes by serving the index.html
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// Start the server
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
// Handle process termination
process.on('SIGINT', () => {
console.log('Shutting down server...');
process.exit(0);
});
process.on('SIGTERM', () => {
console.log('Shutting down server...');
process.exit(0);
});