Spaces:
Sleeping
Sleeping
Download backend/src/modules/subscription/subscription.controller.ts from kishankrish19/Chat: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/subscription/subscription.controller.ts
- Command line
-
hf download hf://spaces/kishankrish19/Chat/backend/src/modules/subscription/subscription.controller.ts
-
curl -L -o subscription.controller.ts https://huggingface.co/spaces/kishankrish19/Chat/resolve/main/backend/src/modules/subscription/subscription.controller.ts
1.67 kB
| import { Controller, Get, Post, Body, UseGuards, Req } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; | |
| import { SubscriptionService } from './subscription.service'; | |
| import { JwtAuthGuard } from '../auth/jwt-auth.guard'; | |
| ('Subscriptions & Payments') | |
| () | |
| export class SubscriptionController { | |
| constructor(private readonly subService: SubscriptionService) {} | |
| ('plans') | |
| ({ | |
| summary: | |
| 'List available plans (Free, Premium Individual, Duo, Family, Student)', | |
| }) | |
| getPlans() { | |
| return this.subService.getPlans(); | |
| } | |
| ('me/subscription') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Get current subscription tier & renewal date' }) | |
| getSubscription(() req: any) { | |
| return this.subService.getSubscription(req.user.userId); | |
| } | |
| ('me/subscription/checkout-session') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Create Stripe Checkout session for upgrade' }) | |
| createCheckoutSession(() req: any, () body: { plan_id: string }) { | |
| return this.subService.createCheckoutSession(req.user.userId, body.plan_id); | |
| } | |
| ('me/subscription/cancel') | |
| (JwtAuthGuard) | |
| () | |
| ({ summary: 'Cancel subscription at period end' }) | |
| cancelSubscription(() req: any) { | |
| return this.subService.cancelSubscription(req.user.userId); | |
| } | |
| ('webhooks/stripe') | |
| ({ | |
| summary: 'Stripe webhook receiver for invoice & payment events', | |
| }) | |
| handleWebhook(() body: any) { | |
| return this.subService.handleStripeWebhook(body); | |
| } | |
| } | |