project init

This commit is contained in:
2026-02-06 02:17:59 +03:00
commit b9d9b9ed17
129 changed files with 22835 additions and 0 deletions

View File

@ -0,0 +1,41 @@
import {
Controller,
Get,
Post,
Body,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { PaymentsService } from './payments.service';
import { CurrentUser } from '../auth/decorators/current-user.decorator';
import { Public } from '../auth/decorators/public.decorator';
import { User } from '@coursecraft/database';
@ApiTags('subscriptions')
@Controller('subscriptions')
export class PaymentsController {
constructor(private paymentsService: PaymentsService) {}
@Get('plans')
@Public()
@ApiOperation({ summary: 'Get available subscription plans' })
async getPlans() {
return this.paymentsService.getPlans();
}
@Post('checkout')
@ApiBearerAuth()
@ApiOperation({ summary: 'Create Stripe checkout session' })
async createCheckoutSession(
@CurrentUser() user: User,
@Body('tier') tier: 'PREMIUM' | 'PRO'
) {
return this.paymentsService.createCheckoutSession(user.id, tier);
}
@Post('portal')
@ApiBearerAuth()
@ApiOperation({ summary: 'Create Stripe customer portal session' })
async createPortalSession(@CurrentUser() user: User) {
return this.paymentsService.createPortalSession(user.id);
}
}