0a9588abb7
- Add pagination support to findAll (page, limit query params) - Add findByTemplateId method to service - Add GET /by-template/:templateId endpoint to controller - Service already includes CRUD for QuestionBank and QuestionBankItem
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Body,
|
|
Param,
|
|
Delete,
|
|
UseGuards,
|
|
Req,
|
|
Query,
|
|
Res,
|
|
} from '@nestjs/common';
|
|
import { CombinedAuthGuard } from '../auth/combined-auth.guard';
|
|
import { PodcastService } from './podcast.service';
|
|
import { Response } from 'express';
|
|
import * as path from 'path';
|
|
|
|
@Controller('podcasts')
|
|
export class PodcastController {
|
|
constructor(private readonly podcastService: PodcastService) {}
|
|
|
|
@Post()
|
|
@UseGuards(CombinedAuthGuard)
|
|
create(@Req() req, @Body() createDto: any) {
|
|
return this.podcastService.create(req.user.id, createDto);
|
|
}
|
|
|
|
@Get()
|
|
@UseGuards(CombinedAuthGuard)
|
|
findAll(@Req() req, @Query('groupId') groupId?: string) {
|
|
return this.podcastService.findAll(req.user.id, groupId);
|
|
}
|
|
|
|
@Get(':id')
|
|
@UseGuards(CombinedAuthGuard)
|
|
findOne(@Req() req, @Param('id') id: string) {
|
|
return this.podcastService.findOne(req.user.id, id);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@UseGuards(CombinedAuthGuard)
|
|
remove(@Req() req, @Param('id') id: string) {
|
|
return this.podcastService.delete(req.user.id, id);
|
|
}
|
|
|
|
// Public route for audio streaming (or protected if preferred)
|
|
@Get('audio/:filename')
|
|
async streamAudio(@Param('filename') filename: string, @Res() res: Response) {
|
|
const filePath = path.join(process.cwd(), 'uploads', 'podcasts', filename);
|
|
res.sendFile(filePath);
|
|
}
|
|
}
|