adorn-api 1.0.38 → 1.0.39
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 +22 -16
- package/package.json +1 -1
- package/src/core/decorators.ts +766 -766
- package/src/core/metadata.ts +131 -125
- package/tests/unit/stage3-metadata-sim.test.ts +138 -0
package/README.md
CHANGED
|
@@ -18,13 +18,15 @@ A modern, decorator-first web framework built on Express with built-in OpenAPI 3
|
|
|
18
18
|
- 🌐 **CORS Support**: Built-in CORS configuration
|
|
19
19
|
- 🏗️ **Lifecycle Hooks**: Application bootstrap and shutdown lifecycle events
|
|
20
20
|
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install adorn-api
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install adorn-api
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Note: Adorn uses Stage 3 decorator metadata (`Symbol.metadata`). If the runtime does not provide it, Adorn polyfills `Symbol.metadata` on import to keep decorator metadata consistent.
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
28
30
|
|
|
29
31
|
### 1. Define DTOs
|
|
30
32
|
|
|
@@ -157,9 +159,9 @@ async getOne(ctx: RequestContext) {
|
|
|
157
159
|
}
|
|
158
160
|
```
|
|
159
161
|
|
|
160
|
-
### DTOs (Data Transfer Objects)
|
|
161
|
-
|
|
162
|
-
DTOs define the shape of data sent to and from your API. They provide validation, documentation, and type safety.
|
|
162
|
+
### DTOs (Data Transfer Objects)
|
|
163
|
+
|
|
164
|
+
DTOs define the shape of data sent to and from your API. They provide validation, documentation, and type safety.
|
|
163
165
|
|
|
164
166
|
```typescript
|
|
165
167
|
@Dto({ description: "User data" })
|
|
@@ -169,12 +171,16 @@ export class UserDto {
|
|
|
169
171
|
|
|
170
172
|
@Field(t.string({ minLength: 2, maxLength: 100 }))
|
|
171
173
|
name!: string;
|
|
172
|
-
}
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
###
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Stage 3 Decorator Metadata
|
|
178
|
+
|
|
179
|
+
Adorn relies on Stage 3 decorator metadata (`Symbol.metadata`) to connect information across decorators (DTO fields, routes, params, etc.). If the runtime does not provide it, Adorn polyfills `Symbol.metadata` on import so decorators share a consistent metadata object.
|
|
180
|
+
|
|
181
|
+
### Request Context
|
|
182
|
+
|
|
183
|
+
Each route handler receives a `RequestContext` object that provides access to:
|
|
178
184
|
- `ctx.body` - The request body (validated and typed)
|
|
179
185
|
- `ctx.params` - Route parameters
|
|
180
186
|
- `ctx.query` - Query parameters
|