A decorator is a function that wraps a class, method, property, or parameter and can attach metadata or modify behavior. NestJS uses decorators extensively — @Module(), @Injectable(), @Controller(), @Get(), @Body() are all decorators — enabled by experimentalDecorators: true in tsconfig.
Decorators are a stage-3 JavaScript proposal and an experimental TypeScript feature. They allow you to annotate and modify classes and their members at design time. NestJS is built entirely around decorators as its primary API.
@Module() — defines module metadata (imports, providers, exports, controllers).
@Injectable() — marks a class as a provider eligible for DI.
@Controller() — marks a class as a request handler with a route prefix.
HTTP decorators (@Get, @Post, etc.) — map methods to HTTP verbs and routes.
Parameter decorators (@Body, @Param, @Query) — extract data from requests.