import { Controller, Get, Post, Body, Param, UseGuards, Req } from '@nestjs/common'; import { AuthService } from './auth.service'; import { CreateKeyDto } from './dto/management/create-key.dto'; import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'; import { FirebaseAuthGuard } from './guards/firebase-auth.guard'; @ApiTags('auth') @ApiBearerAuth() @UseGuards(FirebaseAuthGuard) @Controller('auth/management') export class TenantController { constructor(private readonly authService: AuthService) {} @Post('keys') @ApiOperation({ summary: 'Create a new API key' }) async createKey( @Req() req: any, @Body() dto: CreateKeyDto ) { const tenantId = req.tenant.id; return this.authService.createApiKey( tenantId, dto.name, dto.rateLimit, dto.allowedOrigins ); } @Get('keys') @ApiOperation({ summary: 'Get all API keys for the authenticated tenant' }) async getKeys(@Req() req: any) { const tenantId = req.tenant.id; return this.authService.getApiKeys(tenantId); } @Get('me') @ApiOperation({ summary: 'Get current authenticated tenant info' }) async getMe(@Req() req: any) { return req.tenant; } }