import { Controller, HttpCode, Post, UseGuards } from '@nestjs/common'; import type Stripe from 'stripe'; import { StripeEvent } from './stripe-event.decorator.js'; import { StripeWebhookGuard } from './stripe-webhook.guard.js'; import { WebhooksService } from './webhooks.service.js'; @Controller('webhooks') export class WebhooksController { constructor(private readonly webhooks: WebhooksService) {} @Post('stripe') @HttpCode(200) @UseGuards(StripeWebhookGuard) async stripe(@StripeEvent() event: Stripe.Event): Promise<{ received: true }> { await this.webhooks.handle(event); return { received: true }; } }