Standardize POST /notify/:id response shape — always include stored field
#13
Loading…
Reference in a new issue
No description provided.
Delete branch "mailship-nl0-post-notify-response-shape-ok-skipped-la-387"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
mailship-nl0
Fix a mismatch between the documented POST /notify/:id response contract and the actual implementation: the endpoint now always includes a
storedboolean, even when the event is not found at the relay.Changes
src/server.ts — Changed the "event not found at relay" response from
{ ok: true, skipped: true }to{ ok: true, stored: false }. This standardises the shape to{ ok: true, stored: boolean }across both code paths (event found and event skipped), matching the README.md contract.README.md — Added a paragraph documenting the skip case: when the relay does not have the requested event, the endpoint returns
{ ok: true, stored: false }rather than erroring.test/notify-response-shape.test.ts — New vitest test that creates a confirmed subscription, starts the server, POSTs with a non-existent event ID (mocks
@welshman/net'sloadto return empty), and asserts the response includesstored(notskipped) with valuefalse.How to test
Run
pnpm test:unit— the new testnotify_response_shape > returns stored=false instead of skipped=true when event not foundwill verify the fix. All existing tests continue to pass.Bug: when the event was not found at the relay, the handler returned { ok: true, skipped: true }, which did not match the documented contract { ok: true, stored: boolean } in README.md. Fix: change the 'skipped' response to { ok: true, stored: false }, so the response shape is consistent across all code paths. - src/server.ts: changed line 287 from { ok: true, skipped: true } to { ok: true, stored: false }, with updated comment - README.md: added a note documenting the skip case (stored: false) - test/notify-response-shape.test.ts: new test that asserts stored=false and that skipped is never present