Skip to content

Commit

Permalink
feat(stripe): restrict event string to valid set
Browse files Browse the repository at this point in the history
Restricts the Stripe webhook event type to a valid set provided by the Stripe package.

fix #170
  • Loading branch information
bbangert committed Aug 8, 2020
1 parent a2c2cf7 commit 76d8119
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/stripe/src/stripe.decorators.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { makeInjectableDecorator } from '@golevelup/nestjs-common';
import { SetMetadata } from '@nestjs/common';
import Stripe from 'stripe';
import {
STRIPE_CLIENT_TOKEN,
STRIPE_MODULE_CONFIG_TOKEN,
Expand All @@ -23,5 +24,6 @@ export const InjectStripeClient = makeInjectableDecorator(STRIPE_CLIENT_TOKEN);
* Events will be automatically routed here based on their event type property
* @param config The configuration for this handler
*/
export const StripeWebhookHandler = (eventType: string) =>
SetMetadata(STRIPE_WEBHOOK_HANDLER, eventType);
export const StripeWebhookHandler = (
eventType: Stripe.WebhookEndpointCreateParams.EnabledEvent
) => SetMetadata(STRIPE_WEBHOOK_HANDLER, eventType);

0 comments on commit 76d8119

Please sign in to comment.