A lightweight async dependency injection toolkit for Rust
MIT License
Bot releases are hidden (Show)
Major pivot! Until now, Nakago has been aimed at growing into a full-scale API server framework. However, I've realized that the core value of Nakago is the Dependency Injection system, and that it can be used in a wide variety of contexts. This release is a pivot to focus on the DI system itself, and to make it more flexible and easier to use in a variety of contexts.
Take a look at examples like the Axum / Async-GraphQL demo for more details!
nakago
- Removed Application
, Hooks
, the lifecycle::EventType
and lifecycle::Events
enums. The config
utilities were moved to nakago-figment
.nakago-axum
- Removed AxumApplication
, Route
, and Routes
in favor of a more generic approach. Use the new Inject
extractor to access dependencies in your Axum handlers.nakago-warp
- Removed WarpApplication
, Route
, and Routes
in favor of a more generic approach. Use the with_injection()
Filter to access dependencies in your Warp handlers.nakago
- The tag-based container operations were previously the default mode of working with Inject
. This proved to be more verbose and than necessary in most cases, however. The new default mode is to use the type-based operations, which are more ergonomic and easier to use. The tag-based operations are still available, but they are now suffixed with _tag
to make it clear that they are a different mode of operation. The type-based operations are no longer suffixed with _type
, because they are now the default.nakago
- The inject
namespace has been promoted to the top level. Where nakago::inject
was used before, nakago
should now be the equivalent.nakago
- The config
utilities were moved to nakago-figment
.nakago-examples-simple
, nakago-examples-async-graphql
, nakago-examples-simple-warp
- Updated with the new approach. See these examples for more information about how to use the tools mentioned above.nakago-axum
- Added a new Inject
extractor to access dependencies in your Axum handlers. This is a much more idiomatic way to use Nakago with Axum, and it's more flexible than the previous approach. Use the provided Axum State
to make the Inject
container available to your handlers.nakago-figment
- Generic config utilities extracted from the core nakago
package.Published by bkonkle 3 months ago
nakago-axum
- Changed the Inject
extractor to be a wrapper around the Nakago dependency injection container, rather than a direct extractor. This makes it much more convenient to use it in an idiomatic way with Axum.nakago-async-graphql
- Updated nakago-axum
nakago-ws
- Updated nakago-axum
nakago-examples-async-graphql
- Updated the example to use the new Inject
extractor.Published by bkonkle 3 months ago
nakago-ws
: New package for Websocket utilitiesnakago
: Major change - types are now the primary interface, with tags being used only when needed.
.get_type()
and .provide_type()
have been moved to methods like .get()
and .provide()
, and the existing tag methods were moved to methods like .get_tag()
and .provide_tag()
.nakago-examples-async-graphql
: Updated to use the new nakago-ws
package for Websocket support.nakago-derive
: Properly namespaced the Inject
usagePublished by bkonkle 9 months ago
nakago-example-async-graphql
: Cleaned up some imports that weren't being used.Published by bkonkle 9 months ago
nakago-warp
: A new Warp adapter that works in a similar way to the Axum adapter.nakago-examples-simple-warp
: A new example project that uses the Warp adapter.nakago
: Added a copy of Axum's FromRef
utility, so that it can be used without importing Axum itself.nakago-derive
: Updated to support the FromRef utility.mockall
and tokio-tungstenite
requirements, and removed temporary tokio-tungstenite fork.nakago-axum
: Simplified the route Init Hook.nakago-axum
, nakago-async-graphql
, nakago-sea-orm
: Updated to use the new FromRef utility.Published by bkonkle 11 months ago
This is a big release! It includes updates from http
to v1.0, hyper
to v1.0, and axum
to v0.7. It refactors the test utils to use reqwest
instead of the minimal hyper Client that is changing in v1.0. There are a number of small behind-the-scenes changes to support these new versions, and Nakago is currently relying on a few temporary forks as the community catches up to the big releases in recent weeks.
http
v1.0, hyper
v1.0, and axum
v0.7 across the board.nakago-axum
: AxumApplication.run()
now returns a tuple with the server and the actual address that it is bound to.nakago-axum
: The jwks
utils now use reqwest
to retrieve the "known-hosts.json" file.nakago-axum
: The Route
and Routes
types no longer take a Body
type parameter.nakago-axum
: Moved the test HTTP utilities to reqwest
, eliminating the need for an injected HTTP test client.nakago-async-graphql
: Moved the test HTTP utilities to reqwest
, and made the integration with the plain HTTP test utils more seamless.nakago-axum
: Removed the test::CLIENT
tag, because it is no longer needed.To update your project from Nakago v0.16 to v0.17:
Update all Nakago crates to v0.17.
Update usages of AxumApplication.run()
to use the new return type, which is a tuple of (Server, SocketAddr)
.
// From:
let server = app.run(args.config_path).await?;
let addr = server.local_addr();
// To:
let (server, addr) = app.run(args.config_path).await?;
reqwest
instead of the injected HTTP client. // From:
let req = utils
.http
.call(Method::GET, "/username", Value::Null, Some(&token))?;
let resp = utils.http_client.request(req).await?;
let status = resp.status();
let body = to_bytes(resp.into_body()).await?;
let json: Value = serde_json::from_slice(&body)?;
// To:
let resp = utils
.http
.get_json("/username", Some(&token))
.send()
.await?;
let status = resp.status();
let json = resp.json::<Value>().await?;
Published by bkonkle 11 months ago
nakago-axum
: Add a default Axum AddLoaders
struct that wraps the base nakago::config::AddLoaders
struct.nakago-sea
: Add a default SeaOrm AddLoaders
struct that wraps the base nakago::config::AddLoaders
struct.nakago
: Introduced the derive-new
crate and used it in a few places.nakago-axum
: Introduced the derive-new
crate and used it in a few places.Published by bkonkle 12 months ago
nakago
: Renamed nakago::error
to nakago::errors
nakago-axum
: Moved away from a custom Axum State, using a hardcoded State that simply contains an Inject
container instead.nakago-axum
: Major routing improvements, with drastic simplification from the previous version.nakago-async-graphql
: Reworked things around the new State approach for Axum.nakago-axum
: Added nakago-axum::State
and nakago-axum::Inject
for smoother interop with Axum handlers.nakago-async-graphql
: Added nakago-async-graphql::errors::to_graphql_response
to convert nakago::Error
into a GraphQL response.Published by bkonkle about 1 year ago
Published by bkonkle about 1 year ago
nakago
, nakago-axum
, and nakago-async-graphql
.nakago-axum
to make the mocked authenticate method injectable by DI rather than using build tags.TestUtils
provided in the library.Published by bkonkle about 1 year ago
HttpConfigLoader
to the nakago-axum
crate, and added it to the list of default config loaders for Axum.simple
example with a simple Axum HTTP application with authentication.website/docs/tutorial.md
documentation.Published by bkonkle about 1 year ago
nakago-async-graphql
library with an initial implementation of schema building.Load
, which is intended for use before the config is loaded. During this phase, an Application will typically set up all of its Providers and ConfigLoaders.
Init
Lifecycle Event is now used for constructing anything needed to run the app. This is typically where an Application initializes things like GraphQL schemas, Axum routes, or anything else that needs to make use of Provided dependencies or the loaded Config.Inject::override_tag()
and Inject::override_type()
methods to allow for injecting a dependency whether or not it was already there, returning a boolean result to indicate whether the key already existed or not.inject
module.Published by bkonkle about 1 year ago
nakago-sea-orm
library with an initial implementation of SeaORM Configs, Connections, and Mocked tools for testing.eject
operation, mostly used in testing when you want to unload the container and take ownership of referenced dependencies.#[Provider]
proc macro for trait implementations to automatically provide the necessary impl Provider<Dependency>
needed for the Provider to be injected into the container.<T>
type parameter to Providers, allowing various container methods to warn you before you pass a Provider
that provides the wrong type.