Skip to content

Decorators

Every decorator NestRS ships, grouped by concern, with a one-line summary and a link to the page where it lives.

This page is the index of every decorator the framework ships, grouped by concern. Skim the table for the one you need, click through to the page that explains it in context. Each row says where the decorator goes (struct, impl block, method, field) so you can confirm the position without leaving the page.

What counts as a decorator here: everything you write. That is the whole inclusion rule, and it is wider than “an attribute macro”. Roughly half the rows below — #[get], #[query], #[public], #[on_module_init] — are inert tokens an orchestrator reads (#[routes], #[operations], #[hooks]), not macros of their own, and they need no import. What decides a row is whether you type it, not how the compiler resolves it.

DecoratorGoes onSummaryRead more
#[module]structComposes a binary: lists providers it owns and imports it depends onModules
#[injectable]structMarks a provider built from the container, with optional scope = request | transientProviders
#[inject]fieldResolves the field from the container at constructionProviders
#[hooks]impl blockOrchestrates lifecycle methods on a providerLifecycle
#[on_module_init]methodRuns once after wiring, before servingLifecycle
#[on_application_bootstrap]methodRuns once after every module init, before servingLifecycle
#[on_module_destroy]methodRuns on shutdown after transports stopLifecycle
#[before_application_shutdown]methodRuns before the application begins shutting downLifecycle
#[on_application_shutdown]methodRuns last during shutdown, best-effortLifecycle
DecoratorGoes onSummaryRead more
#[controller]structMounts the struct as a controller with a base path and optional versionControllers
#[routes]impl blockWires methods to HTTP routes and emits the route tableControllers
#[get] #[post] #[put] #[patch] #[delete]methodBinds the method to an HTTP verb at the given pathControllers
#[sse]methodBinds a GET that answers a text/event-stream, with the keep-alive and the connection ceilingStreaming
#[http_code]methodOverrides the default response status codeResponses
#[response_header]methodAppends a response header (repeatable)Responses
#[redirect]methodIssues a redirect and discards the handler payloadResponses
#[use_guards]struct or methodBinds container-resolved Guards, first listed outermostGuards
#[use_interceptors]struct or methodBinds container-resolved InterceptorsInterceptors
#[use_filters]struct or methodBinds error-mapping Filters (response mapping; the global pool runs at the transport band)Exception filters
#[use_exception_filters]struct or methodBinds typed ExceptionFilters — downcast catch, the layer closest to the handlerException filters
#[meta]methodAttaches typed metadata read back via Reflector (repeatable)Guards
#[public]methodMarks the route public so auth guards skip itGuards
#[interceptor]structMarks a struct as a global HTTP interceptorInterceptors
#[version]methodNarrows a route to one of the controller’s declared versionsVersioning
#[force_guards]struct or methodRe-runs a guard the broader scope already ran — the opt-out from dedupGuards
DecoratorGoes onSummaryRead more
#[input]structShorthand for any type that crosses a wire: Serialize + Deserialize + Validate + JsonSchema + deny_unknown_fieldsExtractors

One decorator, one definition — an HTTP body, a GraphQL input, a queue payload, a WS message and a tool’s arguments all take it. Every surface crate re-exports it, so import it from the one the file already uses (nest_rs::http::input, nest_rs::queue::input, nest_rs::mcp::input, nest_rs::ws::input, or nest_rs::core::input) — they are the same macro.

DecoratorGoes onSummaryRead more
#[resolver]structMarks a resolver provider and declares its resolver-scope guardsGraphQL
#[operations]impl blockOrchestrates the block’s #[query] / #[mutation] / #[subscription] / #[entity] / #[field_resolver] methodsGraphQL
#[query]methodRoot query operation; requires an access posture (#[authorize] or #[public])Queries and mutations
#[mutation]methodRoot mutation operation; requires an access posture (#[authorize] or #[public])Queries and mutations
#[subscription]methodRoot subscription over graphql-ws; same posture, gated at subscribe and masked per itemSubscriptions
#[entity]methodFederation entity resolver — the router resolves it by reference through _entities; same mandatory posture, and its arguments are the @keyFederation
#[authorize]methodAccess posture: gates the operation by ability (Action, Entity) and masks the responseQueries and mutations
#[public]methodAccess posture: deliberately ungated operation — no gate, no maskQueries and mutations
#[field_resolver]methodCustom field resolver on a wire type; takes no posture attributeField resolvers
#[dataloader]impl block on serviceBatches a method into a request-scoped DataLoaderDataloader
DecoratorGoes onSummaryRead more
#[gateway]structMounts a WebSocket gateway at a path on the HTTP transportWebSockets
#[messages]impl blockBinds gateway message handlers and lifecycle hooksMessages
#[subscribe_message]methodHandles one event in the { event, data } envelopeMessages
#[on_connect]methodRuns after the socket upgradesRooms
#[on_disconnect]methodRuns after the socket closesRooms
DecoratorGoes onSummaryRead more
#[queue]unit structDeclares a queue’s wire name and payload type in one artifact both producer and consumer importQueue
#[processor]impl blockOrchestrates queue consumers on a providerQueue
#[process]methodBinds the method to a queue with an optional retries budget and transactional settlingQueue
DecoratorGoes onSummaryRead more
#[scheduled]impl blockOrchestrates scheduled methods on a providerSchedule
#[every]methodFires the method on a fixed interval, optional transactionalSchedule
#[cron]methodFires the method on a cron expression, optional tz and transactionalSchedule
#[after]methodFires the method once after a delay from boot, optional transactionalSchedule
DecoratorGoes onSummaryRead more
#[listeners]impl blockOrchestrates event listeners on a providerEvents
#[on_event]methodSubscribes the method to its second-parameter event typeEvents
DecoratorGoes onSummaryRead more
#[mcp]structMounts an MCP endpoint over HTTP, at /mcp or a declared pathMCP
#[tools]impl blockServes the block’s #[tool] and #[prompt] methods, deriving the advertised capabilitiesMCP
#[tool]methodExposes the method as an MCP tool; description = "…", or the doc comment as a fallbackMCP
#[prompt]methodExposes the method as an MCP prompt; description = "…", or the doc comment as a fallbackResources and prompts
DecoratorGoes onSummaryRead more
#[indicators]impl blockOrchestrates health checks on a providerIndicators
#[liveness]methodBinds the method to the liveness probeIndicators
#[readiness]methodBinds the method to the readiness probeIndicators
#[startup]methodBinds the method to the startup probeIndicators
DecoratorGoes onSummaryRead more
#[config]structMarks a struct as a namespaced configuration loaded from env and filesConfiguration
DecoratorGoes onSummaryRead more
#[expose]struct + fieldExposes a SeaORM entity to GraphQL and OpenAPI from one declarationDatabase
#[wire_enum]enumCarries the wire derives for an entity’s enum column, so an #[expose]d field of that type crosses GraphQL and OpenAPIEntities
#[crud]impl blockGenerates standard CRUD operations on a controller or resolverCRUD
DecoratorGoes onSummaryRead more
#[api]methodEnriches the OpenAPI operation with summary, description, and tagsOpenAPI