igrantio-backend-sselisted
Install: claude install-skill L3-iGrant/skills
# iGrant.io backend SSE
## When to use
To notify the browser the moment an OWS webhook lands, instead of polling the OWS
history endpoint. Pairs with `igrantio-backend-webhooks` (which fills the store)
and `igrantio-frontend-client`'s SSE consumer. Composed by the issuer/verifier
backends.
**Before you build**: run the integrator intake in `igrantio-ows-overview` - environment, API key, tenancy, backend host, webhooks, frontend - one question at a time, a recommended default with each.
## What it does
Mounted at `/webhook`:
- `GET /webhook/sse/:exchangeId` - opens a `text/event-stream`, checks the store
each second, emits `data: <event JSON>\n\n` when an event for that id appears,
and sends comment heartbeats to keep the connection alive.
- `DELETE /webhook/:exchangeId` - lets the browser consume-and-delete so a
refresh/reconnect doesn't replay a handled event.
## Reference
[`./references`](./references):
- `sse.ts` - `sseRouter(store)` Express router.
- `eventStore.ts` - the `EventStore` interface + `InMemoryEventStore` (share the
same instance with the webhook receiver).
## Usage
```ts
import { InMemoryEventStore } from "./eventStore";
import { sseRouter } from "./sse";
import { webhookReceiver } from "./webhooks"; // from igrantio-backend-webhooks
const store = new InMemoryEventStore();
app.use("/webhook", webhookReceiver(store)); // POST /webhook fills the store
app.use("/webhook", sseRouter(store)); // GET /sse/:id, DELETE /:id drain it
```
## Scalin