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)}
` : `| id | name | phone | city | plan | mrr | |
|---|---|---|---|---|---|---|
| ${r.id} | ${esc(r.full_name)} | ${esc(r.email)} | ${esc( r.phone )} | ${esc(r.city)} | ${esc(r.plan)} | $${(r.mrr_cents / 100).toFixed( 2 )} |