Skip to main content

Server Decorators

Class Decorators

DecoratorDescriptionDetails
@Controller()Marks a class as a server-side controller. Entry point for commands, events, and handlers.Details
@Service()Marks a class as a reusable service (business logic). Singleton by default.Details
@Bind()Registers a class in the DI container. For utilities, adapters, or low-level classes. Accepts 'singleton' (default) or 'transient'.Details
@Repo()Semantic alias for @Bind(). Intended for data access and persistence layers.Details

Method Decorators

DecoratorArgumentsDescriptionDetails
@Command(){ command, usage?, schema? }Registers a chat/console command handler with optional Zod validation. First param is always Player.Details
@OnNet()eventName: stringSubscribes to a network event (client → server). First param is always Player.Details
@OnRPC()eventName: stringSubscribes to an RPC call. Returns a value to the caller.Details
@OnTick()Executes on every server tick. Use for lightweight, high-frequency logic.Details
@OnFrameworkEvent()eventName: stringListens to internal framework lifecycle events.Details
@OnLibraryEvent()libraryName: string, eventName: stringListens to server-side library domain events emitted through library.emit(...).Details
@OnRuntimeEvent()eventName: stringSubscribes to native FiveM events (playerJoining, playerDropped, etc.).Details
@RequiresState()state: stringEnsures the player has a specific state flag before execution.Details
@Throttle()limit, windowMsRate-limits the method per player or context.Details
@Export()exportName?: stringExposes the method as a FiveM export for inter-resource APIs.Details
@Guard(){ permission?, rank? }Applies access control before execution.Details
@Public()Marks the method as explicitly public, bypassing guards.Details
@BinaryService()serviceId: numberRegisters a binary protocol service handler.Details
@BinaryCall()callId: numberRegisters a binary protocol call handler.Details
@BinaryEvent()eventId: numberRegisters a binary protocol event handler.Details

Execution Order

When multiple decorators are stacked on a method, they execute in this order:

  1. @RequiresState() — State check
  2. @Guard() — Permission/rank check
  3. @Throttle() — Rate limit check
  4. Schema validation — Zod schema (if defined in @Command())
  5. Handler execution — Your method runs