React + Tone.js modular synthesizer with visual node editor. Includes: Oscillator, Filter, Envelope, LFO, VCA, Delay, Reverb, Distortion, Mixer, Scope, Output, and Keyboard modules. SVG wire connections, knob controls, preset save/load system. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
// Lightweight static file server for Reaktor modular synth
|
|
const http = require('http');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const PORT = process.env.PORT || 80;
|
|
const STATIC_DIR = path.join(__dirname, 'dist');
|
|
|
|
const MIME = {
|
|
'.html': 'text/html', '.css': 'text/css', '.js': 'application/javascript',
|
|
'.json': 'application/json', '.png': 'image/png', '.jpg': 'image/jpeg',
|
|
'.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.woff2': 'font/woff2',
|
|
'.wasm': 'application/wasm',
|
|
};
|
|
|
|
const server = http.createServer((req, res) => {
|
|
let filePath = path.join(STATIC_DIR, req.url === '/' ? 'index.html' : req.url);
|
|
|
|
// SPA fallback: if file doesn't exist, serve index.html
|
|
if (!fs.existsSync(filePath) || fs.statSync(filePath).isDirectory()) {
|
|
filePath = path.join(STATIC_DIR, 'index.html');
|
|
}
|
|
|
|
if (!filePath.startsWith(STATIC_DIR)) {
|
|
res.writeHead(403); res.end('Forbidden'); return;
|
|
}
|
|
|
|
const ext = path.extname(filePath).toLowerCase();
|
|
const contentType = MIME[ext] || 'application/octet-stream';
|
|
|
|
fs.readFile(filePath, (err, data) => {
|
|
if (err) {
|
|
res.writeHead(err.code === 'ENOENT' ? 404 : 500);
|
|
res.end(err.code === 'ENOENT' ? 'Not found' : 'Server error');
|
|
return;
|
|
}
|
|
if (['.png', '.jpg', '.woff2', '.js', '.css'].includes(ext)) {
|
|
res.setHeader('Cache-Control', 'public, max-age=604800');
|
|
}
|
|
res.writeHead(200, { 'Content-Type': contentType });
|
|
res.end(data);
|
|
});
|
|
});
|
|
|
|
server.listen(PORT, () => {
|
|
console.log(`[reaktor] Running on port ${PORT}`);
|
|
});
|