-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (30 loc) · 983 Bytes
/
server.js
File metadata and controls
37 lines (30 loc) · 983 Bytes
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
// server.js
// Simple HTTP server for local testing
// ------------------------------------------------------
import express from 'express';
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
import http from 'http';
// Get __dirname equivalent in ES module
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Create express app
const app = express();
const PORT = process.env.PORT || 8000;
// Serve static files from project root
app.use(express.static(__dirname));
// Create http server
const server = http.createServer(app);
// Start server
server.listen(PORT, () => {
console.log(`🎮 Bitstream Bluffs server running at http://localhost:${PORT}`);
console.log(`📁 Serving files from: ${__dirname}`);
});
// Handle server shutdown
process.on('SIGINT', () => {
console.log('🛑 Server shutting down');
server.close(() => {
console.log('👋 Server closed');
process.exit(0);
});
});