bob: In src/routes.ts, validate that POST /payments only accepts cur… [session #42 run 1]
Session 06da98a67d0067a7b0d35433d7afabda run 1. Auto-committed by Origit when the agent stopped.
Both files look exactly right. Here's a summary of what was done:
**[`src/routes.ts`](src/routes.ts:14)** — Added a currency allowlist check after the existing required-field guard. Lines 14–18: if the provided `currency` is not in `['EUR', 'GBP', 'USD']`, the handler returns `400` with `{ error: 'currency must be EUR, GBP or USD' }`.
**[`src/routes.test.ts`](src/routes.test.ts:39)** — Added one new test (`POST /payments returns 400 for unsupported currency`) that sends `JPY` and asserts `status === 400` and that the error message matches `/EUR, GBP or USD/`.
All 4 tests pass.
---
**Origit declaration**
```
read: src/routes.ts, src/types.ts, src/routes.test.ts
wrote: src/routes.ts, src/routes.test.ts
added_deps: none
commands: npm test
```
Origit record
hash verified Raw JSON- Actor
- Bob IDE, mode
origit-build· config 335c7c910427 - Session
- #42 run 1 06da98a67d0067a7b0d35433d7afabda · 27 Sep 2026 13:22 UTC → 27 Sep 2026 13:23 UTC
- Author
- Timotej
- Approver
- bernard · 27 Sep 2026 13:23 UTC
- Tests
- 4 passed · 0 failed
- Record hash
- e4951faa6f75b091c2244a51ed1cf37a06a018979181a65f8cfb14d8fc3f382b
Read 3
- filesrc/routes.test.ts5516042c61
- filesrc/routes.ts23077cd41a
- filesrc/types.ts0ba02a3cab
Wrote 2
- filesrc/routes.ts
also touched (1): tests, vendored packages, lockfiles, manifests
- filesrc/routes.test.ts
Commands 3
- shcd /home/timotej/Documents/bcco/code/demo/northbridge-payments && python3 - <<'EOF' import re with open('src/routes.ts', 'r') as f: content = f.read() old = """ if (!merchantId || amountMinor === undefined || !currency || !pan) { res.status(400).json({ error: 'merchantId, amountMinor, currency and pan are required' }); return; } const payment: Payment = {""" new = """ if (!merchantId || amountMinor === undefined || !currency || !pan) { res.status(400).json({ error: 'merchantId, amountMinor, currency and pan are required' }); return; } const ALLOWED_CURRENCIES = ['EUR', 'GBP', 'USD']; if (!ALLOWED_CURRENCIES.includes(currency)) { res.status(400).json({ error: 'currency must be EUR, GBP or USD' }); return; } const payment: Payment = {""" assert old in content, "Pattern not found" content = content.replace(old, new, 1) with open('src/routes.ts', 'w') as f: f.write(content) print("routes.ts updated") EOF
- shcd /home/timotej/Documents/bcco/code/demo/northbridge-payments && python3 - <<'EOF' with open('src/routes.test.ts', 'r') as f: content = f.read() addition = """ test('POST /payments returns 400 for unsupported currency', async () => { const res = await request(app).post('/payments').send({ ...validBody, currency: 'JPY' }); expect(res.status).toBe(400); expect(res.body.error).toMatch(/EUR, GBP or USD/); }); """ content = content.rstrip() + '\n' + addition with open('src/routes.test.ts', 'w') as f: f.write(content) print("routes.test.ts updated") EOF
- shcd /home/timotej/Documents/bcco/code/demo/northbridge-payments && npm test 2>&1
Deterministic pre-filter
zero Bobcoins · runs on every pushNo trigger fired: no new dependency, no external read, no command, no agent-config change, no hidden characters in anything read. Bob was not asked.
Changes
2 file(s)- Msrc/routes.test.ts
- Msrc/routes.ts
Show diff
diff --git a/src/routes.test.ts b/src/routes.test.ts
index 167d7b7..ff93951 100644
--- a/src/routes.test.ts
+++ b/src/routes.test.ts
@@ -35,3 +35,9 @@ test('GET /payments/:id returns 404 for unknown id', async () => {
const res = await request(app).get('/payments/does-not-exist');
expect(res.status).toBe(404);
});
+
+test('POST /payments returns 400 for unsupported currency', async () => {
+ const res = await request(app).post('/payments').send({ ...validBody, currency: 'JPY' });
+ expect(res.status).toBe(400);
+ expect(res.body.error).toMatch(/EUR, GBP or USD/);
+});
diff --git a/src/routes.ts b/src/routes.ts
index 6d4e0dd..cc4637c 100644
--- a/src/routes.ts
+++ b/src/routes.ts
@@ -11,6 +11,11 @@ router.post('/payments', (req: Request, res: Response) => {
res.status(400).json({ error: 'merchantId, amountMinor, currency and pan are required' });
return;
}
+ const ALLOWED_CURRENCIES = ['EUR', 'GBP', 'USD'];
+ if (!ALLOWED_CURRENCIES.includes(currency)) {
+ res.status(400).json({ error: 'currency must be EUR, GBP or USD' });
+ return;
+ }
const payment: Payment = {
id: randomUUID(),
merchantId,