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

29 lines
1.0 KiB
TypeScript

import { Controller, Post, Body, Res, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
import { Response } from 'express';
import { ExportsService } from './exports.service';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
@ApiTags('exports')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('exports')
export class ExportsController {
constructor(private readonly service: ExportsService) {}
@Post('csv')
@ApiOperation({ summary: 'Export videos as CSV' })
async exportCsv(@Body() body: { videoIds?: string[]; savedViewId?: string }, @Res() res: Response) {
const csv = await this.service.exportCsv(body.videoIds, body.savedViewId);
res.setHeader('Content-Type', 'text/csv');
res.setHeader('Content-Disposition', `attachment; filename="studioflow-export-${Date.now()}.csv"`);
res.send(csv);
}
@Post('json')
@ApiOperation({ summary: 'Export full workspace as JSON' })
exportJson() {
return this.service.exportJson();
}
}