doc: genre, lesson and history controller

This commit is contained in:
GitBluub
2023-09-20 03:41:34 +02:00
committed by Bluub
parent f8be2c2462
commit 29ef585410
3 changed files with 16 additions and 7 deletions
+3 -1
View File
@@ -14,7 +14,7 @@ import {
Req,
StreamableFile,
} from '@nestjs/common';
import { Plage } from 'src/models/plage';
import { ApiOkResponsePlaginated, Plage } from 'src/models/plage';
import { CreateGenreDto } from './dto/create-genre.dto';
import { Request } from 'express';
import { GenreService } from './genre.service';
@@ -22,6 +22,7 @@ import { Prisma, Genre } from '@prisma/client';
import { ApiTags } from '@nestjs/swagger';
import { createReadStream, existsSync } from 'fs';
import { FilterQuery } from 'src/utils/filter.pipe';
import { Genre as _Genre } from 'src/_gen/prisma-class/genre';
@Controller('genre')
@ApiTags('genre')
@@ -65,6 +66,7 @@ export class GenreController {
}
@Get()
@ApiOkResponsePlaginated(_Genre)
async findAll(
@Req() req: Request,
@FilterQuery(GenreController.filterableFields)
+10 -5
View File
@@ -10,12 +10,14 @@ import {
Request,
UseGuards,
} from '@nestjs/common';
import { ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger';
import { ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger';
import { SearchHistory, SongHistory } from '@prisma/client';
import { JwtAuthGuard } from 'src/auth/jwt-auth.guard';
import { SongHistoryDto } from './dto/SongHistoryDto';
import { HistoryService } from './history.service';
import { SearchHistoryDto } from './dto/SearchHistoryDto';
import { SongHistory as _SongHistory } from 'src/_gen/prisma-class/song_history';
import { SearchHistory as _SearchHistory} from 'src/_gen/prisma-class/search_history';
@Controller('history')
@ApiTags('history')
@@ -23,8 +25,9 @@ export class HistoryController {
constructor(private readonly historyService: HistoryService) { }
@Get()
@HttpCode(200)
@ApiOperation({ description: "Get song history of connected user"})
@UseGuards(JwtAuthGuard)
@ApiOkResponse({ type: _SongHistory, isArray: true})
@ApiUnauthorizedResponse({ description: 'Invalid token' })
async getHistory(
@Request() req: any,
@@ -35,8 +38,9 @@ export class HistoryController {
}
@Get('search')
@HttpCode(200)
@ApiOperation({ description: "Get search history of connected user"})
@UseGuards(JwtAuthGuard)
@ApiOkResponse({ type: _SearchHistory, isArray: true})
@ApiUnauthorizedResponse({ description: 'Invalid token' })
async getSearchHistory(
@Request() req: any,
@@ -47,13 +51,14 @@ export class HistoryController {
}
@Post()
@HttpCode(201)
@ApiOperation({ description: "Create a record of a song played by a user"})
@ApiCreatedResponse({ description: "Succesfully created a record"})
async create(@Body() record: SongHistoryDto): Promise<SongHistory> {
return this.historyService.createSongHistoryRecord(record);
}
@Post("search")
@HttpCode(201)
@ApiOperation({ description: "Creates a search record in the users history"})
@UseGuards(JwtAuthGuard)
@ApiUnauthorizedResponse({description: "Invalid token"})
async createSearchHistory(
+3 -1
View File
@@ -13,11 +13,12 @@ import {
Delete,
NotFoundException,
} from '@nestjs/common';
import { Plage } from 'src/models/plage';
import { ApiOkResponsePlaginated, Plage } from 'src/models/plage';
import { LessonService } from './lesson.service';
import { ApiOperation, ApiProperty, ApiTags } from '@nestjs/swagger';
import { Prisma, Skill } from '@prisma/client';
import { FilterQuery } from 'src/utils/filter.pipe';
import { Lesson as _Lesson} from 'src/_gen/prisma-class/lesson';
export class Lesson {
@ApiProperty()
@@ -48,6 +49,7 @@ export class LessonController {
summary: 'Get all lessons',
})
@Get()
@ApiOkResponsePlaginated(_Lesson)
async getAll(
@Req() request: Request,
@FilterQuery(LessonController.filterableFields)