exisjs 0.7.11 → 0.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +195 -39
- package/dist/cli/commands/dev.d.ts +4 -0
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +136 -32
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/commands/run.d.ts +7 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +99 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/index.js +29 -13
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/manifest.d.ts.map +1 -1
- package/dist/cli/manifest.js +18 -3
- package/dist/cli/manifest.js.map +1 -1
- package/dist/cli/routes.d.ts +6 -0
- package/dist/cli/routes.d.ts.map +1 -1
- package/dist/cli/routes.js +224 -135
- package/dist/cli/routes.js.map +1 -1
- package/dist/config/config.d.ts +2 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js.map +1 -1
- package/dist/config/types.d.ts +30 -9
- package/dist/config/types.d.ts.map +1 -1
- package/dist/database/lifecycle.d.ts +6 -1
- package/dist/database/lifecycle.d.ts.map +1 -1
- package/dist/database/lifecycle.js +15 -4
- package/dist/database/lifecycle.js.map +1 -1
- package/dist/decorators/params.d.ts +21 -0
- package/dist/decorators/params.d.ts.map +1 -1
- package/dist/decorators/params.js +21 -1
- package/dist/decorators/params.js.map +1 -1
- package/dist/di/container.d.ts +15 -6
- package/dist/di/container.d.ts.map +1 -1
- package/dist/di/container.js +26 -3
- package/dist/di/container.js.map +1 -1
- package/dist/di/index.d.ts +1 -1
- package/dist/di/index.d.ts.map +1 -1
- package/dist/di/index.js.map +1 -1
- package/dist/di/inject.d.ts +2 -1
- package/dist/di/inject.d.ts.map +1 -1
- package/dist/di/inject.js +2 -1
- package/dist/di/inject.js.map +1 -1
- package/dist/docs/BENCHMARKS.md +4 -4
- package/dist/docs/content/README.md +43 -44
- package/dist/docs/content/boundaries.mdx +141 -48
- package/dist/docs/content/cli/commands.mdx +161 -107
- package/dist/docs/content/cli/overview.mdx +61 -46
- package/dist/docs/content/cli/usage.mdx +107 -30
- package/dist/docs/content/config.mdx +145 -147
- package/dist/docs/content/controllers.mdx +193 -464
- package/dist/docs/content/cron.mdx +183 -69
- package/dist/docs/content/decorators.mdx +449 -154
- package/dist/docs/content/errors.mdx +202 -305
- package/dist/docs/content/exisjs-mcp.mdx +59 -49
- package/dist/docs/content/installation.mdx +243 -157
- package/dist/docs/content/introduction.mdx +220 -48
- package/dist/docs/content/middleware.mdx +171 -497
- package/dist/docs/content/modules.mdx +141 -83
- package/dist/docs/content/providers.mdx +216 -180
- package/dist/docs/content/requests.mdx +168 -488
- package/dist/docs/content/responses.mdx +200 -533
- package/dist/docs/content/routing.mdx +239 -558
- package/dist/docs/content/security.mdx +233 -57
- package/dist/docs/content/structure.mdx +151 -240
- package/dist/docs/content/swagger.mdx +192 -91
- package/dist/docs/content/testing.mdx +205 -74
- package/dist/docs/content/validation.mdx +479 -341
- package/dist/docs/reference/README.md +34 -2
- package/dist/docs/reference/config.mdx +277 -73
- package/dist/docs/reference/context.mdx +197 -106
- package/dist/docs/reference/cron.mdx +266 -152
- package/dist/docs/reference/database.mdx +135 -53
- package/dist/docs/reference/decorators.mdx +234 -116
- package/dist/docs/reference/di.mdx +146 -112
- package/dist/docs/reference/error.mdx +155 -178
- package/dist/docs/reference/exis.mdx +141 -70
- package/dist/docs/reference/logger.mdx +110 -126
- package/dist/docs/reference/middleware.mdx +235 -158
- package/dist/docs/reference/plugin.mdx +136 -64
- package/dist/docs/reference/router.mdx +277 -251
- package/dist/docs/reference/sanitize.mdx +91 -87
- package/dist/docs/reference/swagger.mdx +280 -100
- package/dist/docs/reference/testing.mdx +223 -89
- package/dist/docs/reference/validator.mdx +194 -206
- package/dist/lib/inspect-routes.d.ts +2 -0
- package/dist/lib/inspect-routes.d.ts.map +1 -0
- package/dist/lib/inspect-routes.js +148 -0
- package/dist/lib/inspect-routes.js.map +1 -0
- package/dist/lib/start-server.js +13 -8
- package/dist/lib/start-server.js.map +1 -1
- package/dist/module/module.d.ts +6 -3
- package/dist/module/module.d.ts.map +1 -1
- package/dist/module/module.js +17 -3
- package/dist/module/module.js.map +1 -1
- package/dist/router/controller-registrar.d.ts.map +1 -1
- package/dist/router/controller-registrar.js +26 -4
- package/dist/router/controller-registrar.js.map +1 -1
- package/dist/router/scanner/cron-mounter.d.ts.map +1 -1
- package/dist/router/scanner/cron-mounter.js +9 -2
- package/dist/router/scanner/cron-mounter.js.map +1 -1
- package/dist/server/app.d.ts +3 -1
- package/dist/server/app.d.ts.map +1 -1
- package/dist/server/app.js +29 -8
- package/dist/server/app.js.map +1 -1
- package/dist/server/define.d.ts.map +1 -1
- package/dist/server/define.js +5 -0
- package/dist/server/define.js.map +1 -1
- package/dist/server/request.d.ts +2 -0
- package/dist/server/request.d.ts.map +1 -1
- package/dist/server/request.js +11 -0
- package/dist/server/request.js.map +1 -1
- package/dist/swagger/generator.d.ts.map +1 -1
- package/dist/swagger/generator.js +130 -10
- package/dist/swagger/generator.js.map +1 -1
- package/dist/telemetry/index.d.ts +12 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +121 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/testing/client.d.ts +1 -0
- package/dist/testing/client.d.ts.map +1 -1
- package/dist/testing/client.js +4 -1
- package/dist/testing/client.js.map +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +20 -4
- package/dist/testing/index.js.map +1 -1
- package/dist/validator/builder.d.ts +26 -1
- package/dist/validator/builder.d.ts.map +1 -1
- package/dist/validator/builder.js +31 -0
- package/dist/validator/builder.js.map +1 -1
- package/dist/validator/engine.d.ts +23 -0
- package/dist/validator/engine.d.ts.map +1 -1
- package/dist/validator/engine.js +228 -31
- package/dist/validator/engine.js.map +1 -1
- package/dist/validator/index.d.ts +8 -4
- package/dist/validator/index.d.ts.map +1 -1
- package/dist/validator/index.js +4 -1
- package/dist/validator/index.js.map +1 -1
- package/dist/validator/tex-types.d.ts +15 -0
- package/dist/validator/tex-types.d.ts.map +1 -1
- package/dist/validator/tex-types.js +102 -0
- package/dist/validator/tex-types.js.map +1 -1
- package/dist/validator/tex.d.ts +1 -1
- package/dist/validator/tex.d.ts.map +1 -1
- package/dist/validator/tex.js +3 -1
- package/dist/validator/tex.js.map +1 -1
- package/dist/validator/types.d.ts +1 -0
- package/dist/validator/types.d.ts.map +1 -1
- package/package.json +47 -14
- package/dist/docs/content/dataloader.mdx +0 -170
- package/dist/docs/reference/dataloader.mdx +0 -91
|
@@ -1,167 +1,285 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
description: "API Reference for ExisJS Class-Based
|
|
2
|
+
title: "exisjs/decorators"
|
|
3
|
+
description: "API Reference for ExisJS Class-Based routing, controller decorators, parameter injectors, pipes, security guards, caching, and lifecycle hooks."
|
|
4
|
+
nextUrl: "/docs/reference/database"
|
|
5
|
+
nextTitle: "Database Reference"
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
#
|
|
8
|
+
# `exisjs/decorators`
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
The `exisjs/decorators` module provides TypeScript decorators for Class-Based OOP architecture. It covers routing controllers, HTTP method endpoints, parameter injection, validation pipes, traffic control, security guards, caching, and application lifecycle hooks.
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Module Exports Overview
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import {
|
|
18
|
+
// Routing & Controllers
|
|
19
|
+
Controller,
|
|
20
|
+
Get,
|
|
21
|
+
Post,
|
|
22
|
+
Put,
|
|
23
|
+
Patch,
|
|
24
|
+
Delete,
|
|
25
|
+
Options,
|
|
26
|
+
Head,
|
|
27
|
+
All,
|
|
28
|
+
Ws,
|
|
29
|
+
Sse,
|
|
30
|
+
|
|
31
|
+
// Parameter Injection
|
|
32
|
+
Body,
|
|
33
|
+
RawBody,
|
|
34
|
+
Param,
|
|
35
|
+
Query,
|
|
36
|
+
QueryParam,
|
|
37
|
+
Headers,
|
|
38
|
+
Req,
|
|
39
|
+
Res,
|
|
40
|
+
Next,
|
|
41
|
+
Ip,
|
|
42
|
+
Cookies,
|
|
43
|
+
Cookie,
|
|
44
|
+
State,
|
|
45
|
+
AppCtx,
|
|
46
|
+
Fields,
|
|
47
|
+
UploadedFile,
|
|
48
|
+
UploadedFiles,
|
|
49
|
+
createParamDecorator,
|
|
50
|
+
|
|
51
|
+
// Pipeline, Middleware & Security
|
|
52
|
+
Use,
|
|
53
|
+
UseGuards,
|
|
54
|
+
UseInterceptors,
|
|
55
|
+
UseFilters,
|
|
56
|
+
UsePipes,
|
|
57
|
+
Catch,
|
|
58
|
+
RateLimit,
|
|
59
|
+
Cors,
|
|
60
|
+
IpFilter,
|
|
61
|
+
Timeout,
|
|
62
|
+
Idempotent,
|
|
63
|
+
Dedupe,
|
|
64
|
+
BlockProbes,
|
|
65
|
+
Upload,
|
|
66
|
+
Roles,
|
|
67
|
+
Permissions,
|
|
68
|
+
Public,
|
|
69
|
+
IsPublic,
|
|
70
|
+
AllowAnonymous,
|
|
71
|
+
|
|
72
|
+
// Responses & Metadata
|
|
73
|
+
HttpCode,
|
|
74
|
+
Header,
|
|
75
|
+
Redirect,
|
|
76
|
+
Returns,
|
|
77
|
+
Hosts,
|
|
78
|
+
SetMetadata,
|
|
79
|
+
Reflector,
|
|
80
|
+
|
|
81
|
+
// IoC, Modules & Boundaries
|
|
82
|
+
Injectable,
|
|
83
|
+
Inject,
|
|
84
|
+
Optional,
|
|
85
|
+
Module,
|
|
86
|
+
Global,
|
|
87
|
+
Boundary,
|
|
88
|
+
Server,
|
|
89
|
+
|
|
90
|
+
// Caching, Transactions & Profiling
|
|
91
|
+
Cacheable,
|
|
92
|
+
CacheEvict,
|
|
93
|
+
Transactional,
|
|
94
|
+
Profile,
|
|
95
|
+
|
|
96
|
+
// Cron & Scheduling
|
|
97
|
+
Cron,
|
|
98
|
+
Interval,
|
|
99
|
+
TimeoutTask,
|
|
100
|
+
} from 'exisjs/decorators'
|
|
101
|
+
```
|
|
11
102
|
|
|
12
103
|
---
|
|
13
104
|
|
|
14
105
|
## 1. Controller & Routing
|
|
15
106
|
|
|
16
|
-
### `@Controller(prefixOrOptions?)`
|
|
107
|
+
### `@Controller(prefixOrOptions?, options?)`
|
|
17
108
|
|
|
18
|
-
Marks a class as
|
|
109
|
+
Marks a class as an HTTP controller slice mounted at the specified route prefix.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
function Controller(
|
|
113
|
+
prefixOrOptions?: string | ControllerOptions,
|
|
114
|
+
options?: ControllerOptions
|
|
115
|
+
): ClassDecorator
|
|
116
|
+
```
|
|
19
117
|
|
|
20
|
-
|
|
21
|
-
|
|
118
|
+
#### `ControllerOptions`
|
|
119
|
+
|
|
120
|
+
| Property | Type | Description |
|
|
121
|
+
| :--- | :--- | :--- |
|
|
122
|
+
| `prefix` | `string` | Base URL path for all routes in this controller class. |
|
|
123
|
+
| `host` | `string \| string[]` | Subdomain or host restriction for this controller. |
|
|
124
|
+
| `cors` | `boolean \| CorsConfig` | Controller-scoped CORS configuration. |
|
|
125
|
+
| `tags` | `string[]` | OpenAPI / Swagger tags for documentation grouping. |
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { Controller, Get } from 'exisjs/decorators'
|
|
22
129
|
|
|
23
130
|
@Controller('/users')
|
|
24
131
|
export default class UserController {
|
|
25
|
-
|
|
132
|
+
@Get('/')
|
|
133
|
+
async list() {
|
|
134
|
+
return { users: [] }
|
|
135
|
+
}
|
|
26
136
|
}
|
|
27
137
|
```
|
|
28
138
|
|
|
29
|
-
|
|
30
|
-
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### HTTP Method Decorators
|
|
31
142
|
|
|
32
|
-
|
|
33
|
-
- `@Post(path?, schema?)`
|
|
34
|
-
- `@Put(path?, schema?)`
|
|
35
|
-
- `@Patch(path?, schema?)`
|
|
36
|
-
- `@Delete(path?, schema?)`
|
|
37
|
-
- `@Options(path?, schema?)`
|
|
38
|
-
- `@Head(path?, schema?)`
|
|
39
|
-
- `@Connect(path?, schema?)`
|
|
40
|
-
- `@Trace(path?, schema?)`
|
|
41
|
-
- `@All(path?, schema?)`
|
|
143
|
+
Method decorators register class methods as HTTP route handlers and attach validation schemas.
|
|
42
144
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
145
|
+
| Decorator | HTTP Method | Signature |
|
|
146
|
+
| :--- | :--- | :--- |
|
|
147
|
+
| `@Get(path?, schema?)` | `GET` | `(path?: string, schema?: MethodSchemaInput) => MethodDecorator` |
|
|
148
|
+
| `@Post(path?, schema?)` | `POST` | `(path?: string, schema?: MethodSchemaInput) => MethodDecorator` |
|
|
149
|
+
| `@Put(path?, schema?)` | `PUT` | `(path?: string, schema?: MethodSchemaInput) => MethodDecorator` |
|
|
150
|
+
| `@Patch(path?, schema?)` | `PATCH` | `(path?: string, schema?: MethodSchemaInput) => MethodDecorator` |
|
|
151
|
+
| `@Delete(path?, schema?)` | `DELETE` | `(path?: string, schema?: MethodSchemaInput) => MethodDecorator` |
|
|
152
|
+
| `@Options(path?, schema?)` | `OPTIONS` | `(path?: string, schema?: MethodSchemaInput) => MethodDecorator` |
|
|
153
|
+
| `@Head(path?, schema?)` | `HEAD` | `(path?: string, schema?: MethodSchemaInput) => MethodDecorator` |
|
|
154
|
+
| `@All(path?, schema?)` | Any Method | `(path?: string, schema?: MethodSchemaInput) => MethodDecorator` |
|
|
155
|
+
| `@Sse(path?, schema?)` | SSE Stream | `(path?: string, schema?: MethodSchemaInput) => MethodDecorator` |
|
|
156
|
+
| `@Ws(path?, schema?)` | WebSocket | `(path?: string, schema?: MethodSchemaInput) => MethodDecorator` |
|
|
46
157
|
|
|
47
|
-
|
|
48
|
-
export default class UserController {
|
|
49
|
-
@Get('/:id')
|
|
50
|
-
getUser() {
|
|
51
|
-
return { id: 1 }
|
|
52
|
-
}
|
|
158
|
+
---
|
|
53
159
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
160
|
+
## 2. Parameter Injectors
|
|
161
|
+
|
|
162
|
+
Parameter decorators extract and inject typed data directly into handler method arguments:
|
|
163
|
+
|
|
164
|
+
| Decorator | Signature | Description | Example |
|
|
165
|
+
| :--- | :--- | :--- | :--- |
|
|
166
|
+
| `@Body(property?, ...pipes)` | `(prop?: string, ...pipes: Pipe[])` | Injects parsed request body or subfield. | `@Body() dto: CreateUserDto` |
|
|
167
|
+
| `@RawBody(encoding?)` | `(encoding?: 'string' \| 'utf8' \| { encoding: string })` | Injects unparsed raw `Buffer` or string. | `@RawBody() payload: Buffer` |
|
|
168
|
+
| `@Param(key?, ...pipes)` | `(key?: string, ...pipes: Pipe[])` | Injects URL path parameter. | `@Param('id', ParseIntPipe) id: number` |
|
|
169
|
+
| `@Query(key?, ...pipes)` | `(key?: string, ...pipes: Pipe[])` | Injects query string parameter or dictionary. | `@Query('page') page: number` |
|
|
170
|
+
| `@Headers(name?, ...pipes)` | `(name?: string, ...pipes: Pipe[])` | Injects HTTP request header. | `@Headers('authorization') auth: string` |
|
|
171
|
+
| `@Cookies(name?, ...pipes)` | `(name?: string, ...pipes: Pipe[])` | Injects parsed cookie value or record. | `@Cookies('session') sid: string` |
|
|
172
|
+
| `@State(key?, ...pipes)` | `(key?: string, ...pipes: Pipe[])` | Injects request state dictionary or property. | `@State('user') user: User` |
|
|
173
|
+
| `@UploadedFile(field?)` | `(field?: string)` | Injects single uploaded file object. | `@UploadedFile('avatar') file: ExisFile` |
|
|
174
|
+
| `@UploadedFiles(field?)` | `(field?: string)` | Injects multiple uploaded files. | `@UploadedFiles('docs') files: ExisFile[]` |
|
|
175
|
+
| `@Req()` | `()` | Injects underlying `ExisRequest`. | `@Req() req: Request` |
|
|
176
|
+
| `@Res(options?)` | `(opts?: { passthrough?: boolean })` | Injects underlying `ExisResponse`. | `@Res() res: Response` |
|
|
177
|
+
| `@Next()` | `()` | Injects pipeline `NextFunction`. | `@Next() next: NextFunction` |
|
|
178
|
+
| `@Ip()` | `()` | Injects client IP address string. | `@Ip() ip: string` |
|
|
179
|
+
| `@AppCtx()` | `()` | Injects root Exis application instance. | `@AppCtx() app: App` |
|
|
180
|
+
|
|
181
|
+
### `createParamDecorator(factory)`
|
|
182
|
+
|
|
183
|
+
Factory to create reusable custom parameter decorators:
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import { createParamDecorator } from 'exisjs/decorators'
|
|
187
|
+
|
|
188
|
+
export const CurrentUser = createParamDecorator((data: string | undefined, ctx) => {
|
|
189
|
+
const req = ctx.req
|
|
190
|
+
return data ? req.user?.[data] : req.user
|
|
191
|
+
})
|
|
59
192
|
```
|
|
60
193
|
|
|
61
194
|
---
|
|
62
195
|
|
|
63
|
-
##
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
- `@AppCtx()`: Injects the root ExisJS Application instance.
|
|
74
|
-
- `@Fields(nameOrPipe?)`: Injects non-file multipart form fields.
|
|
75
|
-
- `@UploadedFile()`: Injects the uploaded file (`req.file`) into the method argument.
|
|
76
|
-
- `@UploadedFiles()`: Injects the uploaded files array or dictionary (`req.files`) into the method argument.
|
|
77
|
-
- `@HostParam(nameOrPipe?)`: Injects a subdomain parameter.
|
|
78
|
-
- `@Req()`: Injects the raw ExisJS Request object.
|
|
79
|
-
- `@Res(options?)`: Injects the raw ExisJS Response object (`{ passthrough: true }`).
|
|
80
|
-
- `@Ip()`: Injects the client's IP address.
|
|
81
|
-
- `@Next()`: Injects the Next function.
|
|
82
|
-
- `createParamDecorator(factory)`: Exports a factory to create custom parameter decorators (e.g. `@CurrentUser()`).
|
|
196
|
+
## 3. Transformation & Validation Pipes
|
|
197
|
+
|
|
198
|
+
| Pipe | Options Interface | Description |
|
|
199
|
+
| :--- | :--- | :--- |
|
|
200
|
+
| `ParseIntPipe` | `{ errorHttpStatusCode?: number }` | Parses string to integer, throwing 400 if invalid. |
|
|
201
|
+
| `ParseFloatPipe` | `{ errorHttpStatusCode?: number }` | Parses string to floating point number. |
|
|
202
|
+
| `ParseBoolPipe` | `{ errorHttpStatusCode?: number }` | Parses `"true"`, `"false"`, `1`, `0` to boolean. |
|
|
203
|
+
| `ParseUUIDPipe` | `{ version?: '1' \| '4' \| 'all' }` | Validates UUID strings. |
|
|
204
|
+
| `ParseArrayPipe` | `{ items?: Pipe, separator?: string }` | Splits comma-separated strings and applies item pipes. |
|
|
205
|
+
| `ValidationPipe` | `{ transform?: boolean }` | Validates DTO classes using schema assertions. |
|
|
83
206
|
|
|
84
207
|
---
|
|
85
208
|
|
|
86
|
-
##
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
- `@Idempotent(options?)`: Caches responses based on the `Idempotency-Key` header using native in-memory off-heap storage. Works at class and method level.
|
|
104
|
-
- `@RateLimit(options?)`: Enforces rate limits (e.g. `@RateLimit({ max: 100, windowMs: 60000 })`) at class or method level.
|
|
105
|
-
- `@Cors(options?)`: Enforces Cross-Origin Resource Sharing rules at class or method level.
|
|
106
|
-
- `@IpFilter(options)`: Enforces CIDR and IP allow/deny lists at class or method level.
|
|
107
|
-
- `@Compress()`: Enables automatic Gzip and Brotli compression on responses.
|
|
108
|
-
- `@Dedupe(options)`: Deduplicates concurrent identical requests sharing the same key.
|
|
109
|
-
- `@BlockProbes(options?)`: Intercepts vulnerability scanner probes (`.env`, `/.git`, `/.DS_Store`) and blackholes them without triggering log noise.
|
|
209
|
+
## 4. Pipeline & Middleware Decorators
|
|
210
|
+
|
|
211
|
+
| Decorator | Target | Options / Arguments | Description |
|
|
212
|
+
| :--- | :--- | :--- | :--- |
|
|
213
|
+
| `@Use(...items)` | Class / Method | `(Handler \| Guard \| Interceptor \| Filter)[]` | Attaches middlewares, guards, interceptors, or filters. |
|
|
214
|
+
| `@UseGuards(...guards)` | Class / Method | `Guard[]` | Attaches authorization guards (`canActivate`). |
|
|
215
|
+
| `@UseInterceptors(...interceptors)` | Class / Method | `Interceptor[]` | Attaches response/request interceptors (`intercept`). |
|
|
216
|
+
| `@UseFilters(...filters)` | Class / Method | `Filter[]` | Attaches exception filters (`catch`). |
|
|
217
|
+
| `@Catch(...exceptions)` | Class | `ErrorConstructor[]` | Declares exception types handled by an `ExceptionFilter`. |
|
|
218
|
+
| `@Timeout(ms)` | Class / Method | `number \| TimeoutOptions` | Overrides request timeout threshold in ms (`0` to disable). |
|
|
219
|
+
| `@RateLimit(options)` | Class / Method | `RateLimitOptions` | Enforces rate limits on endpoints. |
|
|
220
|
+
| `@Cors(options)` | Class / Method | `CorsConfig \| boolean` | Enforces CORS configuration. |
|
|
221
|
+
| `@IpFilter(options)` | Class / Method | `IpFilterOptions` | Enforces CIDR IP allow/deny lists. |
|
|
222
|
+
| `@Idempotent(options?)` | Class / Method | `IdempotencyOptions` | Enables off-heap request caching via `Idempotency-Key`. |
|
|
223
|
+
| `@Dedupe(options?)` | Class / Method | `DedupeOptions` | Deduplicates concurrent in-flight requests with identical keys. |
|
|
224
|
+
| `@BlockProbes(options?)` | Class / Method | `BlockProbesOptions` | Blackholes malicious scanner probes (`.env`, `wp-admin`). |
|
|
225
|
+
| `@Upload(field, options?)` | Method | `string, FileUploadOptions` | Configures multipart file upload streaming on the endpoint. |
|
|
110
226
|
|
|
111
227
|
---
|
|
112
228
|
|
|
113
|
-
##
|
|
229
|
+
## 5. Security & Access Control
|
|
114
230
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
231
|
+
| Decorator | Target | Arguments | Description |
|
|
232
|
+
| :--- | :--- | :--- | :--- |
|
|
233
|
+
| `@Permissions(...permissions)` | Class / Method | `string[]` | Enforces required permission strings on the route. |
|
|
234
|
+
| `@Roles(...roles)` | Class / Method | `string[]` | Enforces required user role strings on the route. |
|
|
235
|
+
| `@Public()` / `@IsPublic()` | Class / Method | None | Bypasses global authentication guards. |
|
|
118
236
|
|
|
119
237
|
---
|
|
120
238
|
|
|
121
|
-
##
|
|
239
|
+
## 6. Response Modifiers & Metadata
|
|
122
240
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
241
|
+
| Decorator | Target | Signature | Description |
|
|
242
|
+
| :--- | :--- | :--- | :--- |
|
|
243
|
+
| `@HttpCode(code)` | Method | `(code: number) => MethodDecorator` | Sets the default HTTP status code for successful responses. |
|
|
244
|
+
| `@Header(name, value)` | Method | `(name: string, value: string) => MethodDecorator` | Injects a static HTTP response header. |
|
|
245
|
+
| `@Redirect(url, status?)` | Method | `(url: string, status?: number) => MethodDecorator` | Redirects response to target URL. |
|
|
246
|
+
| `@Returns(schema)` | Method | `(schema: any) => MethodDecorator` | Defines response schema for OpenAPI documentation. |
|
|
247
|
+
| `@Hosts(...hosts)` | Class / Method | `(...hosts: string[]) => any` | Restricts route to specific host/subdomain headers. |
|
|
248
|
+
| `@SetMetadata(key, value)` | Class / Method | `(key: string, value: any) => any` | Attaches custom metadata inspectable via `Reflector`. |
|
|
130
249
|
|
|
131
250
|
---
|
|
132
251
|
|
|
133
|
-
##
|
|
252
|
+
## 7. IoC, Dependency Injection & Modules
|
|
134
253
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
- `Reflector.getAllAndOverride(key, targets)`: Retrieves metadata, overriding higher-level targets with lower-level targets.
|
|
144
|
-
- `Reflector.getAllAndMerge(key, targets)`: Merges array/object metadata across multiple targets.
|
|
254
|
+
| Decorator | Target | Options | Description |
|
|
255
|
+
| :--- | :--- | :--- | :--- |
|
|
256
|
+
| `@Injectable(options?)` | Class | `{ scope?: 'singleton' \| 'request' \| 'transient' }` | Marks a class as an IoC provider managed by the container. |
|
|
257
|
+
| `@Inject(token)` | Constructor / Property | `ProviderToken<T>` | Injects dependency by class, token string, or symbol. |
|
|
258
|
+
| `@Optional()` | Constructor / Property | None | Allows unresolved dependencies to return `undefined` instead of throwing. |
|
|
259
|
+
| `@Module(metadata)` | Class | `ModuleMetadata` | Declares an application module (`imports`, `controllers`, `providers`, `exports`). |
|
|
260
|
+
| `@Global()` | Class | None | Makes module exports globally available without explicit importing. |
|
|
261
|
+
| `@Boundary(config)` | Class | `BoundaryConfig` | Declares a folder-scoped boundary class. |
|
|
145
262
|
|
|
146
263
|
---
|
|
147
264
|
|
|
148
|
-
##
|
|
265
|
+
## 8. Caching, Transactions & Profiling
|
|
149
266
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
- `@Boundary(config)`: Marks a class as a folder-scoped Boundary configuring CORS, headers, exclusions, and pipeline steps.
|
|
157
|
-
- `@Server(config)`: Marks a class as a root server definition.
|
|
267
|
+
| Decorator | Target | Options | Description |
|
|
268
|
+
| :--- | :--- | :--- | :--- |
|
|
269
|
+
| `@Cacheable(options)` | Method | `{ ttl?: number, key?: string \| ((...args) => string) }` | Caches method return value in native off-heap LRU cache. |
|
|
270
|
+
| `@CacheEvict(options)` | Method | `{ key: string \| ((...args) => string) }` | Evicts cached keys upon successful method execution. |
|
|
271
|
+
| `@Transactional(options?)` | Method | `TransactionOptions` | Wraps database queries within an atomic transaction. |
|
|
272
|
+
| `@Profile(options?)` | Method | `{ thresholdMs?: number, warnSlow?: boolean }` | Measures and logs method execution latency. |
|
|
158
273
|
|
|
159
274
|
---
|
|
160
275
|
|
|
161
|
-
##
|
|
276
|
+
## 9. Cron & Scheduling Decorators
|
|
277
|
+
|
|
278
|
+
| Decorator | Target | Signature | Description |
|
|
279
|
+
| :--- | :--- | :--- | :--- |
|
|
280
|
+
| `@Cron(schedule, options?)` | Method | `(schedule: string, options?: CronOptions)` | Schedules method to run according to a standard 5-part cron expression. |
|
|
281
|
+
| `@Interval(ms, options?)` | Method | `(ms: number, options?: IntervalOptions)` | Schedules method to execute repeatedly every `ms` milliseconds. |
|
|
282
|
+
| `@TimeoutTask(ms, options?)` | Method | `(ms: number, options?: TimeoutOptions)` | Schedules method to execute once after `ms` milliseconds following boot. |
|
|
162
283
|
|
|
163
|
-
- `@Cron(schedule: string, options?: CronJobOptions)`: Schedules a class method as a recurring cron job on any `@Injectable()` service.
|
|
164
|
-
- `@Interval(ms: number, options?: IntervalOptions)`: Schedules a class method to execute repeatedly every `ms` milliseconds.
|
|
165
|
-
- `@TimeoutTask(ms: number, options?: TimeoutOptions)` (alias `@ScheduledTimeout`): Schedules a class method to execute once after `ms` milliseconds following application bootstrap.
|
|
166
284
|
|
|
167
285
|
|