# Add Webhook Delivery module Parent: #172 Blocked by: #173 ## Goal Add an internal API module that can create, persist and retrieve `WebhookDelivery` records using the types introduced in #173 This establishes the persistence layer without changing existing webhook dispatch behaviour. ## Proposed solution Create `apps/api/src/modules/WebhookDelivery.ts` containing a `WebhookDeliveryModule`. The module should initially support: - Creating and persisting a `WebhookDelivery`. - Retrieving a `WebhookDelivery` by ID. - Returning `null` when a delivery does not exist. New deliveries should: - Use a generated ID with the `whd_z` prefix. - Reference one Event and one Webhook Endpoint. - Start with `pending` status. - Have `delivered_at` and `claim_until` set to `null`. - Have an empty `attempts` array. - Set `next_attempt_at` so the initial attempt is eligible for processing. Add `WebhookDeliveries` to the collections initialized by `Database.EnsureCollections()`. Follow the structure and dependency-injection patterns used by existing API modules. ## Expected files - `apps/api/src/modules/WebhookDelivery.ts` - `apps/api/src/__tests__/WebhookDelivery.spec.ts` - `apps/api/src/modules/Database.ts` ## Acceptance criteria - `WebhookDeliveryModule` can create and persist a delivery. - Created deliveries use the `whd_z` ID prefix. - Created deliveries contain the expected initial values. - The module can retrieve a persisted delivery by ID. - Retrieving an unknown ID returns `null`. - The `WebhookDeliveries` collection is initialized with other known collections. - Focused tests cover creation, retrieval and missing deliveries. - `npx nx test api` passes. ## Non-goals - Creating or recording delivery attempts - Delivery state transitions - Integration with `EventService` or `WebhookDispatcher` - Retry processing - Scheduler routes - Public API endpoints or request schemas
Activity
Benzilla commentedon Sep 30, 2026
Closed by #175