fix: rename DTO name

This commit is contained in:
Hackntosh 2024-02-03 17:00:10 +00:00
parent 2f33a05eab
commit ac9026aea6
6 changed files with 86 additions and 88 deletions

View file

@ -1,3 +1,3 @@
{
"extends": ["@commitlint/config-conventional"]
"extends": ["@commitlint/config-conventional"]
}

View file

@ -1,4 +1 @@
import { PartialType } from "@nestjs/swagger";
import { CreateKweekDto } from "./create-kweek.dto";
export class UpdateKweekDto extends PartialType(CreateKweekDto) {}
export class UpdateKweekDTO {}

View file

@ -1,93 +1,94 @@
import { FilesInterceptor } from "@nest-lab/fastify-multer";
import {
Controller,
Get,
Post,
Body,
Patch,
Param,
Delete,
UseInterceptors,
UploadedFiles,
Request,
Body,
Controller,
Delete,
Get,
Param,
Patch,
Post,
Request,
UploadedFiles,
UseInterceptors,
} from "@nestjs/common";
import { KweeksService } from "./kweeks.service";
import { CreateKweekDTO } from "./dto/create-kweek.dto";
import { UpdateKweekDto } from "./dto/update-kweek.dto";
import {
ApiBearerAuth,
ApiConsumes,
ApiOperation,
ApiTags,
ApiBearerAuth,
ApiConsumes,
ApiOperation,
ApiTags,
} from "@nestjs/swagger";
import { Public } from "src/public.decorator";
import { FilesInterceptor } from "@nest-lab/fastify-multer";
import { CreateKweekDTO } from "./dto/create-kweek.dto";
import { UpdateKweekDTO } from "./dto/update-kweek.dto";
import { KweeksService } from "./kweeks.service";
@ApiTags("Kweeks")
@Controller("kweeks")
export class KweeksController {
constructor(private readonly kweeksService: KweeksService) {}
constructor(private readonly kweeksService: KweeksService) {}
@Post()
@ApiOperation({ summary: "Creates a kweek" })
@ApiBearerAuth("JWT")
@ApiConsumes("multipart/form-data")
@UseInterceptors(FilesInterceptor("attachments", 4))
create(
@Body() createKweekDto: CreateKweekDTO,
@UploadedFiles() attachments: File,
@Request() req,
) {
return this.kweeksService.create(createKweekDto);
}
@Post()
@ApiOperation({ summary: "Creates a kweek" })
@ApiBearerAuth("JWT")
@ApiConsumes("multipart/form-data")
@UseInterceptors(FilesInterceptor("attachments", 4))
create(
@Body() createKweekDto: CreateKweekDTO,
@UploadedFiles() attachments: File,
@Request() req,
) {
// TODO: Find a way to handle multiple files with Swagger
return this.kweeksService.create(createKweekDto);
}
@Public()
@Get(":id")
@ApiOperation({ summary: "Retrieves information about a kweek" })
findOne(@Param("id") id: string) {
return this.kweeksService.findOne(+id);
}
@Public()
@Get(":id")
@ApiOperation({ summary: "Retrieves information about a kweek" })
findOne(@Param("id") id: string) {
return this.kweeksService.findOne(+id);
}
@Patch(":id")
@ApiOperation({ summary: "Updates a kweek content" })
@ApiBearerAuth("JWT")
update(@Param("id") id: string, @Body() updateKweekDto: UpdateKweekDto) {
return this.kweeksService.update(+id, updateKweekDto);
}
@Patch(":id")
@ApiOperation({ summary: "Updates a kweek content" })
@ApiBearerAuth("JWT")
update(@Param("id") id: string, @Body() updateKweekDto: UpdateKweekDTO ) {
return this.kweeksService.update(+id, updateKweekDto);
}
@Delete(":id")
@ApiOperation({ summary: "Deletes a kweek" })
@ApiBearerAuth("JWT")
remove(@Param("id") id: string) {
return this.kweeksService.remove(+id);
}
@Delete(":id")
@ApiOperation({ summary: "Deletes a kweek" })
@ApiBearerAuth("JWT")
remove(@Param("id") id: string) {
return this.kweeksService.remove(+id);
}
@Post(":id/like")
@ApiOperation({ summary: "Likes a kweek" })
@ApiBearerAuth("JWT")
likeKweek() {}
@Post(":id/like")
@ApiOperation({ summary: "Likes a kweek" })
@ApiBearerAuth("JWT")
likeKweek() {}
@Public()
@Get(":id/comments")
@ApiOperation({ summary: "Retrieves comments of a kweek" })
comments() {}
@Public()
@Get(":id/comments")
@ApiOperation({ summary: "Retrieves comments of a kweek" })
comments() {}
@Public()
@Get(":id/comments/:comment_id")
@ApiOperation({ summary: "Retrieves information about a comment" })
comment() {}
@Public()
@Get(":id/comments/:comment_id")
@ApiOperation({ summary: "Retrieves information about a comment" })
comment() {}
@Patch(":id/comments/:comment_id")
@ApiOperation({ summary: "Updates a comment content" })
@ApiBearerAuth("JWT")
updateComment() {}
@Patch(":id/comments/:comment_id")
@ApiOperation({ summary: "Updates a comment content" })
@ApiBearerAuth("JWT")
updateComment() {}
@Delete(":id/comments/:comment_id")
@ApiOperation({ summary: "Deletes a comment" })
@ApiBearerAuth("JWT")
removeComment() {}
@Delete(":id/comments/:comment_id")
@ApiOperation({ summary: "Deletes a comment" })
@ApiBearerAuth("JWT")
removeComment() {}
@Post(":id/comments/:comment_id/like")
@ApiOperation({ summary: "Likes a comment" })
@ApiBearerAuth("JWT")
likeComment() {}
@Post(":id/comments/:comment_id/like")
@ApiOperation({ summary: "Likes a comment" })
@ApiBearerAuth("JWT")
likeComment() {}
}

View file

@ -1,7 +1,7 @@
import { Injectable } from "@nestjs/common";
import { PrismaService } from "src/prisma/prisma.service";
import { CreateKweekDTO } from "./dto/create-kweek.dto";
import { UpdateKweekDto } from "./dto/update-kweek.dto";
import { UpdateKweekDTO } from "./dto/update-kweek.dto";
@Injectable()
export class KweeksService {
@ -14,7 +14,7 @@ export class KweeksService {
return `This action returns a #${id} kweek`;
}
update(id: number, updateKweekDto: UpdateKweekDto) {
update(id: number, updateKweekDto: UpdateKweekDTO) {
return `This action updates a #${id} kweek`;
}

View file

@ -125,6 +125,6 @@ export class UserController {
@ApiOperation({ summary: "Deletes the account of a logged user" })
@ApiBearerAuth("JWT")
delete(@Request() req) {
return this.userService.delete(req.user.id)
}
return this.userService.delete(req.user.id);
}
}

View file

@ -107,11 +107,11 @@ export class UserService {
}
async updateEmail(
loggedUser: User,
id: string,
email: string,
): Promise<{ message: string }> {
const user = await this.prisma.user.findFirst({
where: { id: loggedUser.id },
where: { id },
});
if (email !== undefined && email.trim() !== user.email) {
@ -124,7 +124,7 @@ export class UserService {
await this.prisma.user.update({
where: {
id: loggedUser.id,
id,
},
data: {
email: email ?? user.email,
@ -136,12 +136,12 @@ export class UserService {
}
async updateName(
loggedUser: User,
id: string,
username: string | undefined,
displayName: string,
): Promise<Pick<User, "username" | "displayName">> {
const user = await this.prisma.user.findFirst({
where: { id: loggedUser.id },
where: { id },
});
if (username !== undefined && username.trim() !== user.username) {
@ -155,7 +155,7 @@ export class UserService {
return await this.prisma.user.update({
where: {
id: loggedUser.id,
id
},
data: {
displayName,