CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/api-idempotency

Idempotent API design — safe retries for POST endpoints, idempotency keys,

93

10.00x
Quality

90%

Does it follow best practices?

Impact

100%

10.00x

Average score across 4 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-4/

Payment Processing Endpoint

Problem Description

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.

Output Specification

Produce:

  1. A server.js (or server.ts) file with an Express app that:

    • Creates a SQLite database using better-sqlite3 with a payments table
    • Has a POST /api/payments route that accepts { customerId, amount, currency } and inserts a payment record
    • Returns the created payment as JSON with a 201 status code
    • Listens on port 3000
  2. A 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.

evals

tile.json