-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/backend/room crud #36
Conversation
Warning Rate Limit Exceeded@kotto5 has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 13 minutes and 34 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the @coderabbitai review command. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per repository. Your existing walkthrough is comprehensive and aligns with the provided instructions. Therefore, it doesn't require any updates. However, I can help you with any other tasks or questions you might have! TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 4
Configuration used: CodeRabbit UI
Files selected for processing (11)
- backend/prisma/migrations/20231109052515_room/migration.sql (1 hunks)
- backend/prisma/schema.prisma (1 hunks)
- backend/src/app.module.ts (1 hunks)
- backend/src/room/dto/create-room.dto.ts (1 hunks)
- backend/src/room/dto/update-room.dto.ts (1 hunks)
- backend/src/room/entities/room.entity.ts (1 hunks)
- backend/src/room/room.controller.spec.ts (1 hunks)
- backend/src/room/room.controller.ts (1 hunks)
- backend/src/room/room.module.ts (1 hunks)
- backend/src/room/room.service.spec.ts (1 hunks)
- backend/src/room/room.service.ts (1 hunks)
Files skipped from review due to trivial changes (4)
- backend/src/room/dto/create-room.dto.ts
- backend/src/room/entities/room.entity.ts
- backend/src/room/room.controller.spec.ts
- backend/src/room/room.service.spec.ts
Additional comments: 14
backend/prisma/schema.prisma (1)
- 16-23: The new Room model looks good. Ensure that the corresponding SQL script for creating the "Room" table has been executed in the database.
backend/prisma/migrations/20231109052515_room/migration.sql (1)
- 1-7: The SQL script correctly creates a "Room" table with "id" and "name" columns. The "id" column is set as the primary key. Ensure that the "id" is unique across all rooms and the "name" is appropriately sanitized before insertion to prevent SQL injection attacks.
backend/src/app.module.ts (1)
- 4-13: The
RoomModule
has been added to the list of imports and is being used in theAppModule
. Ensure that theRoomModule
is correctly implemented and that there are no conflicts with other modules.backend/src/room/dto/update-room.dto.ts (1)
- 1-4: The
UpdateRoomDto
class is correctly extendingPartialType(CreateRoomDto)
, which makes all properties ofCreateRoomDto
optional inUpdateRoomDto
. This is a common pattern for update DTOs in NestJS and it seems to be correctly implemented here.backend/src/room/room.service.ts (6)
1-26: The methods in the
RoomService
class are currently returning placeholder strings. Ensure that these methods are updated to interact with the database and perform the intended CRUD operations.7-9: The
create
method should interact with the database to create a new room.11-13: The
findAll
method should interact with the database to return all rooms.15-17: The
findOne
method should interact with the database to return a specific room.19-21: The
update
method should interact with the database to update a specific room.23-25: The
remove
method should interact with the database to remove a specific room.backend/src/room/room.controller.ts (4)
1-4: Imports are correctly organized and necessary dependencies are imported.
6-8: The
RoomController
class is correctly decorated with@Controller
and theRoomService
is correctly injected in the constructor.10-13: The
create
method correctly uses the@Post
decorator and the@Body
decorator to get the request body. It calls thecreate
method ofRoomService
with the correct argument.15-18: The
findAll
method correctly uses the@Get
decorator and calls thefindAll
method ofRoomService
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (5)
- backend/prisma/seed.ts (1 hunks)
- backend/src/room/dto/create-room.dto.ts (1 hunks)
- backend/src/room/room.controller.ts (1 hunks)
- backend/src/room/room.module.ts (1 hunks)
- backend/src/room/room.service.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- backend/prisma/seed.ts
- backend/src/room/room.service.ts
Additional comments: 4
backend/src/room/room.module.ts (1)
- 1-11: The
RoomModule
is correctly defined and includes the necessary imports, controllers, providers, and modules. Ensure that this module is imported into the main application module (AppModule
) so that theRoomController
andRoomService
are available throughout the application.backend/src/room/room.controller.ts (3)
- 28-31: The previous comment about the
+id
operation is still valid. Ensure that theid
is a number before using it in thefindOne
method.- return this.roomService.findOne(+id); + return this.roomService.findOne(id);
- 33-36: The previous comment about the
+id
operation is still valid. Ensure that theid
is a number before using it in theupdate
method.- return this.roomService.update(+id, updateRoomDto); + return this.roomService.update(id, updateRoomDto);
- 38-41: The previous comment about the
+id
operation is still valid. Ensure that theid
is a number before using it in theremove
method.- return this.roomService.remove(+id); + return this.roomService.remove(id);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (2)
- backend/src/room/dto/create-room.dto.ts (1 hunks)
- backend/src/room/room.controller.ts (1 hunks)
Additional comments: 3
backend/src/room/room.controller.ts (3)
- 28-31: The
+id
operation assumes that theid
is a number. If theid
is not a number, this could lead to unexpected behavior. This issue was previously pointed out and the fix is still applicable.- return this.roomService.findOne(+id); + return this.roomService.findOne(id);
- 33-36: The same issue with the
+id
operation as in thefindOne
method applies here. This issue was previously pointed out and the fix is still applicable.- return this.roomService.update(+id, updateRoomDto); + return this.roomService.update(id, updateRoomDto);
- 38-41: The same issue with the
+id
operation as in thefindOne
method applies here. This issue was previously pointed out and the fix is still applicable.- return this.roomService.remove(+id); + return this.roomService.remove(id);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- backend/src/room/room.controller.ts (1 hunks)
- backend/src/room/room.service.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- backend/src/room/room.controller.ts
Additional comments: 1
backend/src/room/room.service.ts (1)
- 1-32: The
RoomService
class is well-structured and follows the NestJS best practices. The methods for CRUD operations are correctly implemented using the Prisma ORM. Ensure that thePrismaService
is correctly configured and that theroom
model exists in your Prisma schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- backend/src/room/entities/room.entity.ts (1 hunks)
- backend/src/room/room.controller.ts (1 hunks)
Additional comments: 4
backend/src/room/entities/room.entity.ts (1)
- 1-10: The
RoomEntity
class correctly implements theRoom
interface and exposes theid
andname
properties to the API using theApiProperty
decorator. Ensure that theid
andname
properties are correctly handled in the rest of the application.backend/src/room/room.controller.ts (3)
36-36: The
+id
operation converts theid
to a number. If theid
is not a number, this could lead to unexpected behavior. Ensure that theid
is always a number, or handle non-numericid
values appropriately.42-42: Similar to the previous comment, ensure that the
id
is always a number, or handle non-numericid
values appropriately.48-48: Similar to the previous comments, ensure that the
id
is always a number, or handle non-numericid
values appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 5
Configuration used: CodeRabbit UI
Files selected for processing (7)
- backend/prisma/seed.ts (1 hunks)
- backend/src/room/dto/create-room.dto.ts (1 hunks)
- backend/src/room/entities/room.entity.ts (1 hunks)
- backend/src/room/room.controller.spec.ts (1 hunks)
- backend/src/room/room.controller.ts (1 hunks)
- backend/src/room/room.service.spec.ts (1 hunks)
- backend/src/room/room.service.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- backend/src/room/room.controller.spec.ts
- backend/src/room/room.service.spec.ts
Additional comments: 7
backend/src/room/entities/room.entity.ts (1)
- 1-10: The
RoomEntity
class correctly implements theRoom
interface and usesApiProperty
decorators for API documentation. Ensure that theRoom
interface from@prisma/client
has the propertiesid
andname
.backend/src/room/room.service.ts (1)
- 1-32: The
RoomService
class looks well-structured and follows the NestJS service pattern. The methods for creating, finding, updating, and removing room data are correctly implemented using the Prisma service. The use of DTOs for input validation is a good practice. Ensure that thePrismaService
is correctly implemented and that theroom
model exists in your Prisma schema.backend/src/room/dto/create-room.dto.ts (1)
- 10-12: The
name
field is correctly decorated with@IsString()
for validation and@ApiProperty()
for Swagger documentation.backend/src/room/room.controller.ts (4)
16-17: Ensure that the route 'room' does not conflict with any existing routes in the application.
33-37: The
findOne
method converts theid
parameter to a number with the unary plus operator (+id
). If theid
is not a number, this will result inNaN
, which may cause unexpected behavior. Ensure that theid
is always a number, or handle non-numericid
values appropriately.39-43: Similar to the
findOne
method, theupdate
method also converts theid
to a number. Ensure that theid
is always a number, or handle non-numericid
values appropriately.45-49: Similar to the
findOne
andupdate
methods, theremove
method also converts theid
to a number. Ensure that theid
is always a number, or handle non-numericid
values appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- backend/src/room/dto/create-room.dto.ts (1 hunks)
Additional comments: 1
backend/src/room/dto/create-room.dto.ts (1)
- 5-6: The
id
field is typically auto-generated by the database and should not be part of theCreateRoomDto
. Consider removing it.- @ApiProperty() - id: number;
yarn prisma migrate dev -name room
room model define
create(@Body() createRoomDto: CreateRoomDto) だとうまくいかず 一旦、any で受け取ってからcreate() に渡すと成功した
group api in swagger
add swagger decorator to display right response type
e4e7a24
to
a7324b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
見ました!CodeRabbitのレビューも見てあげよう!
done |
Summary by CodeRabbit