Add status page at /
Browse filesFiles changed (2)
18 unmodified lines19202122232418 unmodified lines});app.use(express.json({ limit: "32kb" }));app.get("/healthz", (_req, res) => res.json({ ok: true, mode: "test", stripe: Boolean(stripeReady(true)) }));app.get("/wallet/balance", async (req, res, next) => {try { const currency = String(req.query.currency ?? "usd"); res.json({ currency, balance: await ledger.walletBalance(userId, currency) }); } catch (e) { next(e); }18 unmodified lines192021222324252627282930313233343518 unmodified lines});app.use(express.json({ limit: "32kb" }));app.get("/", (_req, res) => {const on = Boolean(stripeReady(true));res.type("html").send(`<!doctype html><html><head><meta charset="utf-8"><title>ProjectOS Wallet (test mode)</title><style>body{font-family:system-ui,sans-serif;max-width:640px;margin:40px auto;padding:0 16px}code{background:#eee;padding:1px 4px}</style></head><body><h1>ProjectOS Wallet <small>(test mode)</small></h1><p>Stripe: <strong>${on ? "configured (test keys)" : "not configured — funding/webhook routes return 503"}</strong></p><ul><li><a href="/healthz">GET /healthz</a></li><li><a href="/wallet/balance">GET /wallet/balance</a></li><li><a href="/wallet/transactions">GET /wallet/transactions</a></li><li><code>POST /invoices/pay</code></li><li><code>POST /funding/checkout</code></li><li><code>POST /funding/payment-intent</code></li><li><code>POST /webhooks/stripe</code></li></ul><p>No real money: test mode only.</p></body></html>`);});app.get("/healthz", (_req, res) => res.json({ ok: true, mode: "test", stripe: Boolean(stripeReady(true)) }));app.get("/wallet/balance", async (req, res, next) => {try { const currency = String(req.query.currency ?? "usd"); res.json({ currency, balance: await ledger.walletBalance(userId, currency) }); } catch (e) { next(e); }
21 unmodified lines22232425262721 unmodified linesexpect(r.status).toBe(503);expect((await r.json()).error).toBe("Stripe not configured");}expect((await (await fetch(url + "/healthz")).json())).toMatchObject({ ok: true, stripe: false });const pay = await post("/invoices/pay", { invoice: { v: 1, invoice_id: "I1", merchant_id: "m", amount: 400, currency: "usd" } });expect(pay.status).toBe(200);21 unmodified lines22232425262728293031323321 unmodified linesexpect(r.status).toBe(503);expect((await r.json()).error).toBe("Stripe not configured");}const root = await fetch(url + "/");expect(root.status).toBe(200);const html = await root.text();expect(html).toContain("ProjectOS Wallet");expect(html).toContain("not configured");expect(html).toContain('href="/healthz"');expect((await (await fetch(url + "/healthz")).json())).toMatchObject({ ok: true, stripe: false });const pay = await post("/invoices/pay", { invoice: { v: 1, invoice_id: "I1", merchant_id: "m", amount: 400, currency: "usd" } });expect(pay.status).toBe(200);
services/wallet/src/app.ts+11
services/wallet/test/app.test.ts+6