Skip to content
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

Merged
merged 12 commits into from
Nov 9, 2023
Merged

Feat/backend/room crud #36

merged 12 commits into from
Nov 9, 2023

Conversation

kotto5
Copy link
Collaborator

@kotto5 kotto5 commented Nov 9, 2023

Summary by CodeRabbit

  • New Features
    • Introduced a new "Room" feature with capabilities to create, retrieve, update, and delete rooms.
  • Documentation
    • Added Swagger annotations for API documentation in the Room controller.
  • Tests
    • Added test suites for the Room controller and Room service.
  • Chores
    • Integrated the Room module into the application.
    • Added seed data for the Room feature.

Copy link
Contributor

coderabbitai bot commented Nov 9, 2023

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.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 32634e3 and a7324b5.

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!


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 32634e3 and 3647598.
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 the AppModule. Ensure that the RoomModule 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 extending PartialType(CreateRoomDto), which makes all properties of CreateRoomDto optional in UpdateRoomDto. 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 the RoomService 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 the create method of RoomService with the correct argument.

  • 15-18: The findAll method correctly uses the @Get decorator and calls the findAll method of RoomService.

backend/src/room/room.module.ts Outdated Show resolved Hide resolved
backend/src/room/room.controller.ts Outdated Show resolved Hide resolved
backend/src/room/room.controller.ts Outdated Show resolved Hide resolved
backend/src/room/room.controller.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 3647598 and 43d11f4.
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 the RoomController and RoomService 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 the id is a number before using it in the findOne 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 the id is a number before using it in the update 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 the id is a number before using it in the remove method.
- return this.roomService.remove(+id);
+ return this.roomService.remove(id);

backend/src/room/dto/create-room.dto.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 43d11f4 and c048b59.
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 the id is a number. If the id 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 the findOne 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 the findOne 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);

backend/src/room/dto/create-room.dto.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between c048b59 and c9a40d5.
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 the PrismaService is correctly configured and that the room model exists in your Prisma schema.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between c9a40d5 and 7cb3d84.
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 the Room interface and exposes the id and name properties to the API using the ApiProperty decorator. Ensure that the id and name properties are correctly handled in the rest of the application.
backend/src/room/room.controller.ts (3)
  • 36-36: The +id operation converts the id to a number. If the id is not a number, this could lead to unexpected behavior. Ensure that the id is always a number, or handle non-numeric id values appropriately.

  • 42-42: Similar to the previous comment, ensure that the id is always a number, or handle non-numeric id values appropriately.

  • 48-48: Similar to the previous comments, ensure that the id is always a number, or handle non-numeric id values appropriately.

backend/src/room/room.controller.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 7cb3d84 and aa9db91.
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 the Room interface and uses ApiProperty decorators for API documentation. Ensure that the Room interface from @prisma/client has the properties id and name.
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 the PrismaService is correctly implemented and that the room 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 the id parameter to a number with the unary plus operator (+id). If the id is not a number, this will result in NaN, which may cause unexpected behavior. Ensure that the id is always a number, or handle non-numeric id values appropriately.

  • 39-43: Similar to the findOne method, the update method also converts the id to a number. Ensure that the id is always a number, or handle non-numeric id values appropriately.

  • 45-49: Similar to the findOne and update methods, the remove method also converts the id to a number. Ensure that the id is always a number, or handle non-numeric id values appropriately.

backend/src/room/dto/create-room.dto.ts Outdated Show resolved Hide resolved
backend/src/room/dto/create-room.dto.ts Show resolved Hide resolved
backend/prisma/seed.ts Show resolved Hide resolved
backend/src/room/room.controller.ts Show resolved Hide resolved
backend/prisma/seed.ts Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between aa9db91 and e4e7a24.
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 the CreateRoomDto. Consider removing it.
- @ApiProperty()
- id: number;

yarn prisma migrate dev -name room
create(@Body() createRoomDto: CreateRoomDto) だとうまくいかず
一旦、any で受け取ってからcreate() に渡すと成功した
group api in swagger
add swagger decorator to display right response type
add prismaservice
room controller and service need PrismaService
@kotto5 kotto5 merged commit 44c963c into main Nov 9, 2023
4 checks passed
@kotto5 kotto5 deleted the feat/backend/room-crud branch November 9, 2023 08:52
Copy link
Owner

@usatie usatie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

見ました!CodeRabbitのレビューも見てあげよう!

backend/src/room/dto/create-room.dto.ts Show resolved Hide resolved
@kotto5
Copy link
Collaborator Author

kotto5 commented Nov 18, 2023

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants