nestrs-core
Runtime traits and types for nestrs: dependency injection (ProviderRegistry, Injectable), module graph hooks, route metadata (RouteRegistry), guards, pipes, and auth strategy extension points.
You rarely depend on this crate alone in application code; the main framework re-exports what you need via nestrs::prelude::*. Use nestrs-core when building extensions or custom modules without pulling the full HTTP stack.
Docs: docs.rs/nestrs-core · Repo: github.com/Joshyahweh/nestrs
Install
[]
= "0.3.0"
= "0.7"
= "0.1"
Example: custom injectable
use async_trait;
use ;
use Arc;
;
Example: register in a ProviderRegistry
use ProviderRegistry;
let mut registry = new;
registry.;
let clock = registry.;
Module / ModuleGraph implementations in higher-level crates call register_providers and register_controllers using these primitives.
NestJS fundamentals parity (custom providers, module ref, discovery, lazy modules)
Full narrative (scopes, lifecycle, dynamic modules, circular deps): Fundamentals in the repo mdBook source.
- Custom providers:
register_use_value(NestuseValue),register_use_factory(NestuseFactory, any [ProviderScope]; factory is sync—useon_module_initor async module options for I/O),register_use_class(alias ofregister/ NestuseClassfor normal injectables). - Module reference:
ModuleRef— resolve providers from anArc<ProviderRegistry>after the graph is built (NestApplication::module_refin the main crate). - Discovery:
DiscoveryServicelists registered providerTypeIds / type names andRouteRegistryHTTP routes. - Execution context:
ExecutionContext+HostTypemirror Nest’sArgumentsHostbasics for HTTP (install middleware from thenestrscrate). - Platform hook:
HttpServerEngine/AxumHttpEnginedocuments the Axum-first “platform” story. - Lazy modules:
DynamicModule::lazy::<M>()or#[module(imports = [lazy_module::<M>()])]/lazy::<M>()in thenestrsproc macro.
Cargo features
test-hooks— exposesRouteRegistry::clear_for_tests()andMetadataRegistry::clear_for_tests()so integration tests can reset process-global registries. Do not enable in production. See workspaceSTABILITY.md.
License
MIT OR Apache-2.0.