Files
youtube-studio-flow/backend/src/modules/video-configs/video-configs.controller.ts
T

30 lines
1.4 KiB
TypeScript

import { Controller, Get, Put, Post, Param, Body, UseGuards, Req } from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { TeamRole } from '@prisma/client';
import { VideoConfigsService } from './video-configs.service';
import { UpsertVideoConfigDto } from './dto/upsert-video-config.dto';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { RolesGuard } from '../auth/guards/roles.guard';
import { Roles } from '../auth/decorators/roles.decorator';
@ApiTags('video-configs')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard, RolesGuard)
@Controller('video-configs')
export class VideoConfigsController {
constructor(private readonly service: VideoConfigsService) {}
@Get(':videoId') @ApiOperation({ summary: 'Get config for a video' })
findOne(@Param('videoId') videoId: string) { return this.service.findByVideoId(videoId); }
@Put(':videoId') @Roles(TeamRole.EDITOR) @ApiOperation({ summary: 'Save/update video config' })
upsert(@Param('videoId') videoId: string, @Body() dto: UpsertVideoConfigDto, @Req() req: any) {
return this.service.upsert(videoId, dto, req.user.id);
}
@Post(':videoId/render-preview') @ApiOperation({ summary: 'Preview render without saving' })
renderPreview(@Param('videoId') videoId: string, @Body() dto: UpsertVideoConfigDto) {
return this.service.renderPreview(videoId, dto);
}
}