Files
ultimate-frisbee/drills/flat-stack-presejpacky/server.ts

22 lines
594 B
TypeScript

import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
const PORT = process.env.PORT || 3000;
// Serve static files from the 'dist' directory
app.use(express.static(path.join(__dirname, 'dist')));
// Fallback to index.html for Single Page Application routing
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'dist', 'index.html'));
});
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});