// MM-Work owns sign-in. Add backend routes only after verifying an MM-Work pass (see the module GUIDE). import { createServer } from 'node:http'; import { readFile } from 'node:fs/promises'; createServer(async (req, res) => { const path = new URL(req.url ?? '/', 'http://localhost').pathname; if (path === '/health') { res.writeHead(200, { 'content-type': 'application/json' }); res.end(JSON.stringify({ ok: true })); return; } if (path === '/module.js') { try { const bundle = await readFile(new URL('../module/dist/module.js', import.meta.url)); res.writeHead(200, { 'content-type': 'text/javascript', 'access-control-allow-origin': '*' }); res.end(bundle); return; } catch { /* no bundle yet: return 404, not an unhandled rejection */ } } res.writeHead(404); res.end('Not found'); }).listen(Number(process.env.PORT || 3000), '0.0.0.0');