Skip to content

Rust · NestJS-style modules & decorators

The Rust framework for modular, scalable backends.

You write the business logic; NestRS carries authentication, tenant isolation, field masking and transactions — declared as decorators, verified at boot.
×2.0
throughput, guarded route
183k req/s on one core · ×1.3 on a bare hello
×17
less memory
6 MB idle · NestJS ~100 MB
×22
faster cold start
~10 ms · NestJS ~220 ms
0.46
p99 latency, ms
guarded route · ×2.9 lower, no GC pauses
0
unguarded routes
an ungated, unmasked surface cannot ship

Measured on NestRS 7.0 against NestJS 12.4 on node:http, its fastest adapter, one core each, byte-identical contract — the harness is in the repo.

02 — SECURITY

A controller that looks like any controller — the security is in what you don’t write. Two declarations, and every route is authenticated, tenant-scoped and field-masked.

Two guards on the struct. Every route below requires a valid token and an ability — forgetting one is a boot error, not a 3am incident.

The handlers are generated. No security code inside — rows are filtered and fields masked on the way out, automatically.

Policy lives in one place. Which rows, which fields, for whom — one ability rule, applied to every transport.

See it live — the security checkpoint →
users/http/controller.rsa normal controller
#[controller(path = "/users")]#[use_guards(AuthnGuard, AuthzGuard)]● 1pub struct UsersController {    #[inject] svc: Arc<UsersService>,} #[crud(service = UsersService)]● 2impl UsersController {}
authz/ability.rsone place for policy
ab.can(Action::Read, user::Entity)    .when(|p| p.eq(user::Column::OrgId, actor.org_id))  // your org only    .fields([user::Column::Id, user::Column::Name]);  // email never leaves● 3
two tokens, one route
❯ curl :3002/users -H "…Bearer $ADMIN"[{ "name": "Acme Admin", "email": "admin@acme.test", … }] ❯ curl :3002/users -H "…Bearer $MEMBER"[{ "id": "…", "name": "Acme Admin" }]  # email masked, org-scoped ❯ curl :3002/users/<globex-id> -H "…$MEMBER"403  # cross-tenant read refused, by the framework

03 — PERFORMANCE

NestRS 7.0 against NestJS 12.4 on node:http — the adapter NestJS recommends and measures ahead of Express and Fastify, so the one worth racing. Same service, byte-identical contract, one pinned core each, the regime that favours Node. just bench in bench/ runs the protocol on your hardware.

Hello world (T1) — 1 core, req/s×1.3
NestRS~201k
NestJS~154k
Guarded route (T2) — req/s×2.0
NestRS~183k
NestJS~93k
JSON body read (T4) — req/s×2.1
NestRS~196k
NestJS~94k
Latency p99, guarded route×2.9
NestRS0.46 ms
NestJS1.32 ms
Memory idle×17
NestRS6 MB
NestJS103 MB
Cold start → first 200×22
NestRS~10 ms
NestJS~220 ms

05 — GUARANTEES

Secure by composition

Authn, row-level filtering, response masking, transaction scope — turned on by importing a module, never by remembering to call them.

Boot, not 3am

The DI graph is checked at boot: a bad import fails startup with the missing wire named. No resolution error five minutes after deploy.

Declarative decorators

78 decorators expanding to plain Rust you can read with cargo expand — no reflection, no magic strings.

Types you don't fight

Rust types end to end — entity, DTO, handler, schema, OpenAPI doc. No any, no casts at the boundaries.

Native throughput

×2 NestJS on node:http, its fastest adapter, on a guarded route — with a sub-millisecond p99 and no GC pauses.

One lean artifact

A native binary for a distroless image — ~10 MB under load, ~10 ms to boot, probes for the orchestrator.

06 — SCALABILITY

Entities, services and policy live once in a shared features crate; each app under apps/* is a thin composition root importing only the transports it serves. Every workload scales on its own signal, and one app importing them all is a plain monolith: microservice scaling without the distributed-systems tax.

PUBLICexposed to clients
App A :3000a public surface
App B :3001another public surface
shared featuresone model — every app builds on it
PRIVATEoff the request path
App Cbackground work
App Dmore background work

Who runs where is a composition choice in each app's module.rs, not a fork of entities and services.

Scale each workload on its own signal
App A :3000demand · high traffic
App B :3001demand · steady
App C queue · backlog
App D queue · light

Same binary, more replicas, per app — a hot public surface follows demand, background apps follow queue depth. No single "scale the monolith" knob.

Service Weaver’s goal, with the queue and the database where it draws RPC. The architecture →

Coming from NestJS, the vocabulary carries over. Coming from Rust, the drift-prone parts stop being yours to police.

❯ nestrs new helloGet started