createWebhookProjectionHandler
API reference for createWebhookProjectionHandler
Function: createWebhookProjectionHandler()
Section titled “Function: createWebhookProjectionHandler()”createWebhookProjectionHandler<
TEvent
>(projection
): (request
) =>Promise
<Response
>
Create a projection handler with webhook support This is platform-agnostic and works with any Request/Response implementation
Type Parameters
Section titled “Type Parameters”TEvent
Section titled “TEvent”TEvent
extends Readonly
<{ data
: EventData
; metadata?
: PlatformEventMetadata
; type
: string
; }>
The event type(s) the projection can handle
Parameters
Section titled “Parameters”projection
Section titled “projection”Projection
<TEvent
>
The projection instance to handle events
Returns
Section titled “Returns”A webhook handler function that processes HTTP requests
(
request
):Promise
<Response
>
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”Promise
<Response
>
Example
Section titled “Example”const projection = new UserProjection(store);const webhookHandler = createWebhookProjectionHandler(projection);
// Use in Cloudflare Worker, Vercel Edge Function, etc.export default { fetch: webhookHandler };