Idempotent API design — safe retries for POST endpoints, idempotency keys,
93
90%
Does it follow best practices?
Impact
100%
10.00xAverage score across 4 eval scenarios
Passed
No known issues
Build a POST /api/payments endpoint for a small billing service. The endpoint accepts a JSON body with { customerId, amount, currency } and creates a payment record. In a real system this would charge the customer's card, but for this exercise just store the payment in a SQLite database and return the record.
Produce:
A server.js (or server.ts) file with an Express app that:
better-sqlite3 with a payments tablePOST /api/payments route that accepts { customerId, amount, currency } and inserts a payment record201 status codeA schema.sql file containing the DDL for the payments table.
The service should be production-quality — handle errors properly, validate inputs, and follow best practices for a financial endpoint.