import { Controller, Post, Body, Headers, UseGuards, UnauthorizedException } from '@nestjs/common'; import { ExternalServicesService } from './external-services.service'; import { IsNotEmpty, IsString } from 'class-validator'; class SaveStripeKeyDto { @IsNotEmpty() @IsString() secretKey: string; } @Controller('admin/credentials') export class ExternalServicesController { constructor(private readonly externalServicesService: ExternalServicesService) { } @Post('stripe') async saveStripeKey( @Body() dto: SaveStripeKeyDto, @Headers('authorization') authHeader: string ) { if (!authHeader) { throw new UnauthorizedException('Missing Authorization header'); } return await this.externalServicesService.saveStripeKey(dto.secretKey, authHeader); } }