2 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
a5f66616c4 |
BLOG-104 Implement CRUD functionality for Posts (#108)
All checks were successful
Frontend CI / build (push) Successful in 1m8s
### Description This pull request introduces the core functionality for creating and updating posts, completing the backend CRUD operations for the `post` feature. It includes new API endpoints, database schema changes, and corresponding updates across the entire application stack from the database layer to the frontend. #### Backend API - **Added new authenticated endpoints:** - `POST /post`: To create a new post. - `PUT /post/{id}`: To update an existing post. - Implemented the full vertical slice for these operations, including: - `CreatePostUseCase` and `UpdatePostUseCase`. - Repository and DB service methods for creating, updating, and associating posts with labels. - Transactional database operations to ensure data integrity when creating/updating posts and their associated labels. #### Database - Added a new migration to include an `"order"` column in the `post_label` table. - This column preserves the user-defined order of labels for each post. - Queries have been updated to fetch and sort labels based on this new column. #### API Schema & Documentation - Enhanced `utoipa` OpenAPI documentation with more specific formats for data types: - `#[schema(format = Uri)]` for URLs like `preview_image_url`. - `#[schema(format = Email)]` for user emails. - `#[schema(format = DateTime)]` for timestamps. - Standardized the `published_time` field to use the RFC3339 string format instead of a numeric timestamp, improving API clarity and interoperability. #### Frontend - Updated the `PostInfoResponseDto` in the frontend to correctly parse the new `DateTime` (ISO string) format for `published_time`. #### Refactoring - Renamed `get_full_post` to a more descriptive `get_post_by_id` across the post feature module for better code clarity. ### Package Changes ```toml utoipa = { version = "5.4.0", features = [ "actix_extras", "non_strict_integers", "url", ] } ``` ### Screenshots _No response_ ### Reference Resolves #104 ### Checklist - [x] A milestone is set - [x] The related issuse has been linked to this branch Reviewed-on: #108 Co-authored-by: SquidSpirit <squid@squidspirit.com> Co-committed-by: SquidSpirit <squid@squidspirit.com> |
|||
c39a800b6b |
BLOG-43 Post related api endpoints (#55)
All checks were successful
Frontend CI / build (push) Successful in 2m18s
### Description - `GET` `/post_info` Get all the info of the posts. - `200` Without any post ```json [] ``` - `200` With posts ```json [ { "description": "This is the first post.", "id": 1, "labels": [ { "color": "#FF666666", "id": 2, "name": "Rust" } ], "preview_image_url": "https://squidspirit.com/icon/logo-light.svg", "published_time": null, "title": "The First Post" } ] ``` - `GET` `/post/{id}` Get the full post content with the given `id` - `200` With result ```json { "content": "Hello! I'm Squid!!", "id": 1, "info": { "description": "This is the first post.", "id": 1, "labels": [ { "color": "#FF666666", "id": 2, "name": "Rust" } ], "preview_image_url": "https://squidspirit.com/icon/logo-light.svg", "published_time": null, "title": "The First Post" } } ``` - `404` There is no post with the `id` ### Package Changes ```toml [workspace.package] version = "0.1.1" edition = "2024" [workspace.dependencies] actix-web = "4.10.2" async-trait = "0.1.88" chrono = "0.4.41" dotenv = "0.15.0" env_logger = "0.11.8" futures = "0.3.31" log = "0.4.27" serde = { version = "1.0.219", features = ["derive"] } sqlx = { version = "0.8.5", features = [ "chrono", "macros", "postgres", "runtime-tokio-rustls", ] } tokio = { version = "1.45.0", features = ["full"] } ``` ### Screenshots _No response_ ### Reference Resolves #43 ### Checklist - [x] A milestone is set - [x] The related issuse has been linked to this branch Reviewed-on: #55 Reviewed-by: zoe <zoe@noreply.localhost> Co-authored-by: SquidSpirit <squid@squidspirit.com> Co-committed-by: SquidSpirit <squid@squidspirit.com> |