mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-29 13:05:18 +02:00
webhook-relay
In-memory webhook relay. Accepts delivery requests over HTTP and POSTs each payload to its destination URL, retrying failures with exponential backoff.
HTTP API
POST /deliveries— body{ "url": string, "payload": any }. Responds202with{ "id" }and delivers asynchronously.400for invalid JSON.GET /deliveries/:id—200with{ "id", "url", "status", "attempts", "lastError" }, or404.statusispending,delivered, ordead.
Delivery contract
- The payload is POSTed to
urlwithcontent-type: application/json. - Any 2xx response means success:
statusbecomesdelivered. - Any other outcome (non-2xx, connection error, timeout) is a failure and is retried with exponential backoff: the first retry happens after about 100ms and the delay doubles each retry. Up to 20% jitter in either direction is fine.
- At most 5 attempts are made in total (the initial try plus 4 retries).
- After the final failure the delivery becomes
deadandlastErrorrecords a short description of the last failure. attemptsalways reflects how many delivery attempts were made.
Module contract
src/app.jsis CommonJS and exportscreateRelay(), which returns anhttp.Serverthat is not yet listening.node src/index.js <port>starts the service.- No external dependencies; Node.js standard library only.
- Run the tests with
npm test.