Skip to content

Commit

Permalink
feat(be): update add creator api
Browse files Browse the repository at this point in the history
  • Loading branch information
harisato committed Oct 10, 2023
1 parent ca1588a commit 3ebba4e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/creator/creator.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Body,
ClassSerializerInterceptor,
Controller,
Get,
Param,
Post,
Put,
Expand All @@ -22,12 +23,18 @@ import {
UpdateCreatorParamDto,
UpdateCreatorRequestDto,
} from './dto/update-creator-request.dto';
import { GetCreatorParamDto } from './dto/get-creator-request.dto';

@Controller('creator')
@ApiTags('creator')
export class CreatorController {
constructor(private readonly creatorSvc: CreatorService) {}

@Get(':slug')
get(@Param() param: GetCreatorParamDto) {
return this.creatorSvc.get(param.slug);
}

@UseGuards(AuthGuard, RolesGuard)
@ApiBearerAuth()
@Roles(Role.Admin)
Expand All @@ -36,7 +43,7 @@ export class CreatorController {
@UseInterceptors(AuthUserInterceptor, AnyFilesInterceptor())
create(
@Body() data: CreateCreatorRequestDto,
@UploadedFiles() files: Array<Express.Multer.File>,
@UploadedFiles() files: Array<Express.Multer.File>
) {
return this.creatorSvc.create(data, files);
}
Expand All @@ -49,12 +56,12 @@ export class CreatorController {
@UseInterceptors(
AuthUserInterceptor,
ClassSerializerInterceptor,
AnyFilesInterceptor(),
AnyFilesInterceptor()
)
update(
@Param() param: UpdateCreatorParamDto,
@Body() data: UpdateCreatorRequestDto,
@UploadedFiles() files: Array<Express.Multer.File>,
@UploadedFiles() files: Array<Express.Multer.File>
) {
const { creatorId } = param;
return this.creatorSvc.update(creatorId, data, files);
Expand Down
8 changes: 8 additions & 0 deletions src/creator/dto/get-creator-request.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString } from 'class-validator';

export class GetCreatorParamDto {
@ApiProperty()
@IsString()
slug: string;
}

0 comments on commit 3ebba4e

Please sign in to comment.