-
Notifications
You must be signed in to change notification settings - Fork 5
Layered (old PR - before branch rename) #153
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
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
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.
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.
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.
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.
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.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
…typo in feed summary
…s and design principles
…ethods - Updated article response DTO to encapsulate article details within an 'article' object. - Refactored articles service methods to improve type handling and ensure consistent article data mapping. - Removed unused query parameters in article fetching logic for cleaner service calls. - Enhanced error handling in article creation and update methods to ensure articles are found post-operation. - Cleaned up comments and organized imports for better code readability.
- Introduced a new mapping function `toFeedResponse` for transforming article data into the feed response format. - Updated the articles controller to utilize `toFeedResponse` for article data mapping. - Modified DTO exports to include `article-feed-response.dto` and reorganized existing exports for clarity. - Changed the author type in the article feed interface to `ProfileFeed` for better alignment with the new response structure.
…handling - Replaced `articlesPlugin` with `articlesController` in the app module for improved structure. - Updated article schema imports across various files to maintain consistency. - Refactored `CommentsRepository` to use a new `CreateCommentDto` type for better clarity and type safety. - Cleaned up unused imports and comments for enhanced code readability.
- Modified summary descriptions in the articles controller for clarity, changing 'Article Feed' to 'Feed Articles', 'Add Comment to Article' to 'Add Comments to an Article', and 'Get Comments from Article' to 'Get Comments from an Article'. - Updated the tags plugin summary from 'List Tags' to 'Get Tags' for consistency. - Adjusted user plugin summaries, changing 'Register' to 'Registeration', 'Login' to 'Authentication', and 'Current User' to 'Get Current User' for improved clarity.
- Moved the article creation endpoint to a new position within the articles controller for improved readability and structure. - Ensured the endpoint retains its functionality, including user authentication and response formatting. - Updated the endpoint's summary details to maintain consistency with other routes.
- Replaced `ListArticlesQueryDto` with `ArticleFeedQueryDto` in the articles controller to enhance query handling for the article feed. - Added a detailed description for the feed articles endpoint, specifying additional query parameters. - Removed the now obsolete `article-feed-response.dto.ts` file to streamline the DTO structure. - Updated DTO exports in the index file to reflect the changes.
- Added a detailed description to the 'List Articles' endpoint, outlining the default behavior and available query parameters for filtering results. - Clarified that authentication is optional and specified the ordering of returned articles.
- Introduced new response mapping functions for articles and comments, enhancing the clarity and consistency of the API responses. - Removed the obsolete `article.dto.ts` file and updated the `create-article.dto.ts` to eliminate the slug field. - Enhanced the `ArticlesResponseDto` and `CommentResponseDto` to better encapsulate response structures. - Updated the comments repository and service to improve type handling and ensure accurate data retrieval. - Cleaned up imports and organized code for better readability.
- Updated the `toDomain` function to accept an optional `tagList` parameter, allowing for more flexible article data representation. - Enhanced the article creation process to update the tag list based on the result of the upsert operation. - Ensured consistent handling of `currentUserId` by using `undefined` instead of `null` for better type safety.
- Simplified tag list handling by destructuring `tagList` from the article object. - Updated the `upsertArticleTags` method call to improve clarity and maintainability. - Enhanced the `toDomain` function to include the updated `tagList`, ensuring accurate representation of article data.
- Renamed the `comment` field to `body` in the comment response DTO for clarity. - Removed the article mapping from the comment response and service, simplifying the data structure. - Cleaned up unused imports and improved type handling in the comments service.
- Introduced type aliases for `FindFilters` and `FindOptions` to enhance code clarity and maintainability. - Simplified the parameter destructuring in the `find` method, improving readability and type safety.
- Consolidated multiple CTEs into a single base query for improved readability and performance. - Simplified the handling of authors, favorites, and tags using coalesce and exists functions. - Enhanced the overall structure of the query to reduce complexity and improve maintainability.
- Added a new ConflictError class to handle duplicate article titles. - Implemented unique slug generation for articles based on the author's username and existing slugs. - Updated error handling in the errorHandler to include ConflictError with appropriate status codes. - Improved logging for error codes and statuses in the app module.
- Updated followUser method to accept username as the first parameter for clarity. - Added a check to prevent following a user that is already followed, throwing a ConflictError if applicable. - Introduced findFollowByUsers method in ProfilesRepository to check existing follow relationships. - Enhanced error messages for better user feedback.
- Renamed variables for clarity, changing 'existingFollow' to 'isFollowing'. - Updated followUser method to prevent following a user if already followed. - Enhanced unfollowUser method to check if the user is being followed before attempting to unfollow. - Simplified error handling by removing unnecessary checks and ensuring consistent return values.
- Eliminated console logging of error codes and statuses in the app module to streamline error handling. - Improved clarity by focusing on setting the appropriate error status without extraneous output.
|
Renamed branch and continued in #163 |
### Description <!-- Provide a comprehensive description here about what your PR aims to solve. --> <!-- You may also add additional context --> - Rearranged the architecture into layered architecture, focusing on articles (making minimal changes in other features just to support the articles feature) - Fixed API summaries to match https://realworld-docs.netlify.app/specifications/backend/endpoints For context see [the added ARCHITECTURE.md file](https://github.com/agnyz/bedstack/blob/3bae8b09298d43d0019bbf1609287790d25c82a5/ARCHITECTURE.md). Continued from #153 --- ### PR Checklist <!-- Please do not remove this section --> <!-- Mark each item with an "x" ([ ] becomes [x]) --> - [x] Read the Developer's Guide in [CONTRIBUTING.md](https://github.com/agnyz/bedstack/blob/main/CONTRIBUTING.md) - [x] Use a concise title to represent the changes introduced in this PR - [x] Provide a detailed description of the changes introduced in this PR, and, if necessary, some screenshots - [x] Reference an issue or discussion where the feature or changes have been previously discussed - [x] Add a failing test that passes with the changes introduced in this PR, or explain why it's not feasible - [x] Add documentation for the feature or changes introduced in this PR to the docs; you can run them with `bun docs` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a comprehensive, RESTful articles and comments API with full CRUD operations, authentication, and validation. - Added support for article feeds, favoriting, and following authors. - Enhanced error handling with more descriptive error responses. - Implemented new endpoints and DTOs for articles, comments, and user profiles. - **Bug Fixes** - Improved type safety and consistency across data models and API responses. - **Documentation** - Added detailed architecture and project structure documentation. - **Refactor** - Restructured codebase for better modularity, type safety, and maintainability. - Replaced and reorganized schema and interface definitions for articles and comments. - **Chores** - Updated configuration files for linting, formatting, and tooling. - Enhanced TypeScript configuration and path aliases. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Description
Rearranged the architecture into layered architecture.
For context see the added ARCHITECTURE.md file.
PR Checklist
bun docs