feat: make flat-stack-presejpacky standalone with Docker and Makefile
This commit is contained in:
21
drills/flat-stack-presejpacky/server.ts
Normal file
21
drills/flat-stack-presejpacky/server.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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}`);
|
||||
});
|
||||
Reference in New Issue
Block a user