We're only logging the error, but not transforming it into an HTTP response, so there is no need for using the custom AppResult type.
AppResult is something from the HTTP/API layer and the models modules shouldn't know anything about that. This PR reduces the coupling a little bit by replacing AppResult with QueryResult where possible.
There is no need to use BoxedAppError if the only error returned from a function is a diesel error.
Previously we were creating these Transport instances per email that we send, but that seems a bit unnecessary. Creating them once on server startup allows us to fail early for configuration issues.
Our in-memory implementation was …
This allows us to fail early if the value can't be parsed into a Mailbox
This is what we use in production so we may as well use it in tests too
Getting a new connection for every loop iteration seems a bit wasteful…
Instead of calling dotenvy::var("DOMAIN_NAME") over and over we can read the value from the server config struct and save it inside the Emails instance 🎉
This removes the tight coupling between the HTTP/API layer with its AppResult struct and the email module, which should not know anything about HTTP or our API.
This PR converts static PUBLIC_KEY_CACHE_LIFETIME_SECONDS: i64 to const PUBLIC_KEY_CACHE_LIFETIME: Duration since most of the work can already be performed at compile time.
This reduces some of the verbose code in the models/owner module a bit.
When diesel returns an error it doesn't always mean that the resource couldn't be found, it could also be any other kind of error. A couple of places in the codebase were unconditionally transforming diesel errors into "could not fin…
This PR extracts our top-level github module into a dedicated workspace package. This makes it easier to enforce the decoupling between the GitHub client code and our HTTP API layer.
Bearer is the official standard scheme (see https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml), while token is a GitHub-specific variant. According to https://docs.github.com/de/rest/authentication/authenticati…
This reduces the need for e.is::<NotFound>() checks and makes the code a little less coupled to our HTTP layer and its error responses.
This seems slightly easier on the eyes compared to the let-if-let-else construct before.
The Runner should not unnecessarily share its connections with anything on the outside, so instead of using the Runner::connection() fn this PR replaces it with TestDatabase::connect(), which uses the connection pool inside the `Te…
This fixes the following issue:
$ cargo test --package crates_io_worker
error[E0432]: unresolved import `tokio::time`
--> crates_io_worker/src/worker.rs:13:12
|
13 | use tokio::time::sleep;
| ^^^^ could ...
This has confused me too many times, so now it will be fixed :D
Having a short list of all the structs is surely nice, but if it then becomes complicated to find their impl blocks it's just not worth it, especially if not all the stru…
These tests don't appear to be related to our routing code at all, so this commit moves them into the module where most of the tested code comes from.
cargo before 1.34.0 only showed raw JSON errors when a non-200 status code was returned. In crates.io we are using the cargo_err() fn in many places to ensure that the error that is returned uses the 200 OK status code. As can be see…