const http = require("http"); const os = require("os"); const { Pool } = require("pg"); const pool = new Pool({ connectionString: process.env.DATABASE_URL }); const label = process.env.APP_LABEL || "VeilStream demo"; const port = Number(process.env.PORT || 3000); const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ }[c])); async function page() { let rows = []; let dbError = null; try { const r = await pool.query( "SELECT id, full_name, email, phone, city, plan, mrr_cents FROM customers ORDER BY id" ); rows = r.rows; } catch (err) { dbError = err.message; } const body = dbError ? `

Database unreachable: ${esc(dbError)}

` : ` ${rows .map( (r) => `` ) .join("\n ")}
idnameemailphonecityplanmrr
${r.id}${esc(r.full_name)}${esc(r.email)}${esc( r.phone )}${esc(r.city)}${esc(r.plan)}$${(r.mrr_cents / 100).toFixed( 2 )}

${rows.length} rows. If these values look like real people, the seed was not sanitized.

`; return ` ${esc(label)}

${esc(label)}

hostname
${esc(os.hostname())}
served at
${new Date().toISOString()}
node
${esc(process.version)}
${body} `; } http .createServer(async (req, res) => { if (req.url === "/healthz") { res.writeHead(200, { "content-type": "text/plain" }); return res.end("ok\n"); } res.writeHead(200, { "content-type": "text/html; charset=utf-8" }); res.end(await page()); }) .listen(port, "0.0.0.0", () => console.log(`listening on ${port}`));