Prepared demo files and demo explanation file. Added debug only button to trigger demo file ingest on the server to queue and prepare the files. Added small expressjs server for talking between the web app and the rust engine containers.

This commit is contained in:
Christbru 2025-10-19 05:55:41 -05:00
commit a03969e497
28 changed files with 232 additions and 7 deletions

44
web-app/server.mjs Normal file
View file

@ -0,0 +1,44 @@
import express from 'express';
import path from 'node:path';
import helmet from 'helmet';
import cors from 'cors';
import { fileURLToPath } from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
const PORT = process.env.PORT || 3000;
const RUST_ENGINE_BASE = process.env.RUST_ENGINE_BASE || 'http://rust-engine:8000';
app.use(helmet());
app.use(cors());
app.use(express.json());
// Proxy minimal API needed by the UI to the rust-engine container
app.post('/api/files/import-demo', async (req, res) => {
try {
const qs = req.url.includes('?') ? req.url.substring(req.url.indexOf('?')) : '';
const url = `${RUST_ENGINE_BASE}/api/files/import-demo${qs}`;
const upstream = await fetch(url, { method: 'POST' });
const text = await upstream.text();
res.status(upstream.status).type(upstream.headers.get('content-type') || 'application/json').send(text);
} catch (err) {
console.error('import-demo proxy failed:', err);
res.status(502).json({ error: 'proxy_failed' });
}
});
// Serve static frontend
const distDir = path.resolve(__dirname, 'dist');
app.use(express.static(distDir));
// SPA fallback
app.get('*', (req, res) => {
res.sendFile(path.join(distDir, 'index.html'));
});
app.listen(PORT, '0.0.0.0', () => {
console.log(`Web app server listening on http://0.0.0.0:${PORT}`);
console.log(`Proxying to rust engine at ${RUST_ENGINE_BASE}`);
});