Commit 2d99377
committed
feat(backend): idempotency-key support for POST /api/donations (Stellar-IndigoPay#148)
- Add idempotency_keys table (migration 016, schema.sql)
- Add validateIdempotencyKey, lookupIdempotencyKey, storeIdempotencyKey
helpers in donations.js; replay cached response within 24-hour window
- Add idempotencyCleanup.js pg-boss cron (IDEMPOTENCY_CLEANUP_CRON,
default '5 * * * *') to purge rows older than 24h; 'disabled' to turn off
- Wire cleanup start + graceful-shutdown hook in server.js
- Update frontend/lib/api.ts recordDonation() to accept idempotencyKey
and send as Idempotency-Key header
- Update DonateForm.tsx and bridge.tsx to generate crypto.randomUUID()
per attempt
- Document Idempotency-Key header param and 200 replay response in
docs/api/openapi.yaml
- Add 8 unit tests (idempotencyCleanup.test.js), 3 testcontainers
integration tests, and 12 new idempotency cases in donations.test.js
Closes Stellar-IndigoPay#1481 parent 761c0bd commit 2d99377
8 files changed
Lines changed: 403 additions & 653 deletions
File tree
- backend/src
- db
- routes
- docs/api
- frontend
- components
- lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
0 commit comments