{"id":15138201,"url":"https://github.com/edo1z/rust-rocket-sqlx-sample","last_synced_at":"2025-09-05T06:38:17.385Z","repository":{"id":195334594,"uuid":"692716549","full_name":"edo1z/rust-rocket-sqlx-sample","owner":"edo1z","description":"A clean architecture style Sample using Rust's Rocket, sqlx and PostgreSQL.","archived":false,"fork":false,"pushed_at":"2024-11-12T05:58:07.000Z","size":140,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-12T22:47:57.310Z","etag":null,"topics":["clean-architecture","postgresql","rocket","rust","sqlx"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edo1z.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-17T11:14:29.000Z","updated_at":"2025-08-01T08:51:14.000Z","dependencies_parsed_at":"2023-12-05T08:24:54.699Z","dependency_job_id":"a2d08022-d1e4-4ca8-b1f4-26e0e251d089","html_url":"https://github.com/edo1z/rust-rocket-sqlx-sample","commit_stats":null,"previous_names":["net3i/rocket-2","edo1z/rust-rocket-sqlx-sample"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/edo1z/rust-rocket-sqlx-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edo1z%2Frust-rocket-sqlx-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edo1z%2Frust-rocket-sqlx-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edo1z%2Frust-rocket-sqlx-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edo1z%2Frust-rocket-sqlx-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edo1z","download_url":"https://codeload.github.com/edo1z/rust-rocket-sqlx-sample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edo1z%2Frust-rocket-sqlx-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273723192,"owners_count":25156302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-architecture","postgresql","rocket","rust","sqlx"],"created_at":"2024-09-26T07:21:09.887Z","updated_at":"2025-09-05T06:38:17.363Z","avatar_url":"https://github.com/edo1z.png","language":"Rust","readme":"# rust-rocket-sqlx-sample\n\n![GitHub](https://img.shields.io/github/license/net3i/rust-rocket-sqlx-sample)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/net3i/rust-rocket-sqlx-sample)\n![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/net3i/rust-rocket-sqlx-sample)\n![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/edo1z)\n\n\nA clean architecture style Sample using Rust's [Rocket](https://rocket.rs/)(v0.5), [sqlx](https://github.com/launchbadge/sqlx)(v0.6) and PostgreSQL.\n\n## How to Use\n\n```shell\ngit clone https://github.com/edo1z/rust-rocket-sqlx-sample\ncd rust-rocket-sqlx-sample\ndocker-compose up -d\ncp .env.example .env\nsh migrate.sh\ncargo test\ncargo run\n```\n\n## Features\n- Tests for controller, use_case, and repository are created using [mockall](https://github.com/asomers/mockall).\n- In the repository integration tests, transactions are created and rolled back in each function, enabling parallel execution of tests.\n- In the repository, `DbRepoError` is returned and converted to `AppError` in use_case. `AppError` corresponds to Rocket's [responder](https://api.rocket.rs/v0.5/rocket/response/trait.Responder.html), so it can be used as a response as is.\n- When an error occurs in the repository, an error log is output. Error log output uses [tracing](https://github.com/tokio-rs/tracing/tree/v0.1.x), and outputs the circumstances leading up to the log, file path, and line number. Also, the values of each function's arguments can be logged.\n- When logging, the conversion from `sqlx::Error` etc. to `DbRepoError` is also performed, so the dedicated macro `log_into!` is used.\n- AppError also has error creation macros like anyhow, `app_err!`, `app_err_bail!`, `app_err_ensure!`.\n\n## Error Log Output\n\nBy using the features of [tracing](https://github.com/tokio-rs/tracing/tree/v0.1.x) and adding the [instrument attribute](https://docs.rs/tracing/latest/tracing/attr.instrument.html) to the function you want to output, the function will be output in the course of error occurrence. The arguments of the function can also be output. To prevent important information from leaking into the log, we generally use [skip_all](https://docs.rs/tracing/latest/tracing/attr.instrument.html#skipping-fields) to hide all arguments and explicitly display the arguments you want to show. Also, by using the `log_into!` macro, the file name and line number of the error occurrence are also output.\n\n```rust\n#[instrument(name = \"user_repo/update\", skip_all, fields(id = %id))]\n```\n\n### Example of Error Log Output\n\n```log\n2023-12-05T07:43:24.644738Z ERROR user_controller/update{id=12}:user_use_case/update{id=12}:user_repo/update{id=12}: rust_rocket_sqlx_sample::repositories::user_repo: [DbRepoError::SqlxError] no rows returned by a query that expected to return at least one row (src/repositories/user_repo.rs:85)\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedo1z%2Frust-rocket-sqlx-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedo1z%2Frust-rocket-sqlx-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedo1z%2Frust-rocket-sqlx-sample/lists"}