nestrs 0.3.1

NestJS-like API framework for Rust on top of Axum and Tower.
Documentation

nestrs

NestJS-style modules, controllers, dependency injection, and HTTP routes on Axum and Tower.

Repository: github.com/Joshyahweh/nestrs · Docs: docs.rs/nestrs

Install

[dependencies]
nestrs = "0.3.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Optional features (enable in Cargo.toml): ws, graphql, openapi, microservices, microservices-nats, microservices-redis, microservices-kafka, microservices-mqtt, microservices-rabbitmq, microservices-grpc, cache-redis, schedule, queues, cookies, session, csrf (requires cookies), otel, and others — see Cargo.toml.

Minimal app

use nestrs::prelude::*;
use std::sync::Arc;

#[injectable]
struct Greeter;

impl Greeter {
    fn hello(&self) -> &'static str {
        "Hello, nestrs!"
    }
}

#[controller(prefix = "/")]
#[routes(state = Greeter)]
impl HelloController {
    #[get("/")]
    async fn hello(State(g): State<Arc<Greeter>>) -> &'static str {
        g.hello()
    }
}

#[module(controllers = [HelloController], providers = [Greeter])]
struct AppModule;

#[tokio::main]
async fn main() {
    NestFactory::create::<AppModule>().listen_graceful(3000).await;
}

Ecosystem crates

Crate Role
nestrs-core DI container, module traits, route registry
nestrs-macros #[module], #[controller], #[get], …
nestrs-events In-process event bus
nestrs-cqrs Command/query buses
nestrs-ws WebSocket gateway helpers
nestrs-graphql async-graphql router
nestrs-openapi OpenAPI + Swagger UI
nestrs-microservices Transports (NATS, Redis, Kafka, MQTT, RabbitMQ, …)
nestrs-prisma Prisma-oriented DB module
nestrs-scaffold CLI (cargo install nestrs-scaffold, binary nestrs)

See the workspace README for badges, benchmarks, and contribution guides.

License

Licensed under MIT OR Apache-2.0, matching the workspace.