Skip to content

Commit 28f5eec

Browse files
committed
export webApiWebhookHandler
1 parent 5e4eb20 commit 28f5eec

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/handlers/platforms/fetch-api/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export * from "./create-protected-handler";
44
export * from "./platform-adapter";
55
export * from "./saleor-webhooks/saleor-async-webhook";
66
export * from "./saleor-webhooks/saleor-sync-webhook";
7+
export { WebApiWebhookHandler } from "./saleor-webhooks/saleor-webhook";

src/handlers/platforms/fetch-api/saleor-webhooks/saleor-webhook.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ export type WebhookConfig<Event = AsyncWebhookEventType | SyncWebhookEventType>
1414
GenericWebhookConfig<WebApiHandlerInput, Event>;
1515

1616
/** Function type provided by consumer in `SaleorWebApiWebhook.createHandler` */
17-
export type WebApiWebhookHandler<TPayload = unknown, TExtras = {}> = (
17+
export type WebApiWebhookHandler<TPayload = unknown> = (
1818
req: Request,
19-
ctx: WebhookContext<TPayload> & TExtras
19+
ctx: WebhookContext<TPayload>,
2020
) => Response | Promise<Response>;
2121

22-
export abstract class SaleorWebApiWebhook<
23-
TPayload = unknown,
24-
TExtras extends Record<string, unknown> = {}
25-
> extends GenericSaleorWebhook<WebApiHandlerInput, TPayload, TExtras> {
26-
createHandler(handlerFn: WebApiWebhookHandler<TPayload, TExtras>): WebApiHandler {
22+
export abstract class SaleorWebApiWebhook<TPayload = unknown> extends GenericSaleorWebhook<
23+
WebApiHandlerInput,
24+
TPayload
25+
> {
26+
createHandler(handlerFn: WebApiWebhookHandler<TPayload>): WebApiHandler {
2727
return async (req) => {
2828
const adapter = new WebApiAdapter(req);
2929
const prepareRequestResult = await super.prepareRequest<WebApiAdapter>(adapter);
@@ -34,7 +34,6 @@ export abstract class SaleorWebApiWebhook<
3434

3535
debug("Incoming request validated. Call handlerFn");
3636
return handlerFn(req, {
37-
...(this.extraContext ?? ({} as TExtras)),
3837
...prepareRequestResult.context,
3938
});
4039
};

0 commit comments

Comments
 (0)