@hazeljs/core 0.2.0-beta.73 → 0.2.0-beta.75

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.
Files changed (2) hide show
  1. package/README.md +29 -4
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -215,6 +215,28 @@ export class UserController {
215
215
  }
216
216
  ```
217
217
 
218
+ ### Custom metadata and parameter decorators
219
+
220
+ Attach custom metadata for guards or other layers with **SetMetadata** / **getMetadata**, and build your own parameter decorators with **createParamDecorator**:
221
+
222
+ ```typescript
223
+ import { SetMetadata, getMetadata, createParamDecorator } from '@hazeljs/core';
224
+
225
+ // Custom metadata (e.g. for guards)
226
+ @SetMetadata('roles', ['admin'])
227
+ class AdminController {}
228
+
229
+ // Custom parameter decorator
230
+ const CurrentUser = createParamDecorator((_req, ctx) => ctx.user);
231
+
232
+ @Get('profile')
233
+ getProfile(@CurrentUser user: User) {
234
+ return user;
235
+ }
236
+ ```
237
+
238
+ Use the custom param decorator **without** parentheses: `@CurrentUser`. See the [full API reference](https://hazeljs.com/docs/api-reference) for `ParamDecoratorContext` and `CUSTOM_METADATA_PREFIX`.
239
+
218
240
  ## Middleware
219
241
 
220
242
  ### Global Middleware
@@ -504,10 +526,13 @@ Startup and registration logs (controllers, routes, providers) are at `debug` le
504
526
  - `@Controller(path)` - Define a controller
505
527
  - `@Injectable(options?)` - Mark class as injectable
506
528
  - `@Get(path?)`, `@Post(path?)`, `@Put(path?)`, `@Delete(path?)`, `@Patch(path?)` - HTTP methods
507
- - `@Param(name)`, `@Query(name)`, `@Body()`, `@Headers(name)` - Parameter extraction
508
- - `@UseMiddleware(middleware)` - Apply middleware
509
- - `@UseGuard(guard)` - Apply guard
510
- - `@UseInterceptor(interceptor)` - Apply interceptor
529
+ - `@Param(name)`, `@Query(name)`, `@Body()`, `@Headers(name)`, `@Req()`, `@Res()`, `@Ip()`, `@Host()` - Parameter extraction
530
+ - `@UseGuards(...guards)`, `@UseInterceptors(...interceptors)`, `@UsePipes(...pipes)` - Apply guards, interceptors, pipes
531
+ - `@Public()` / `@SkipAuth()` - Mark route as public
532
+ - `@Timeout(ms)`, `@Retry(options)`, `@Optional()`, `@Session()` - Per-route behavior
533
+ - `@ApiTags(...tags)`, `@ApiOperation(options)` - OpenAPI metadata
534
+ - **SetMetadata(key, value)** - Attach custom metadata to a class or method (read with `getMetadata(key, target, propertyKey?)`)
535
+ - **createParamDecorator(resolve)** - Build custom parameter decorators that inject values from `(req, context, container)`
511
536
 
512
537
  ### Classes
513
538
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hazeljs/core",
3
- "version": "0.2.0-beta.73",
3
+ "version": "0.2.0-beta.75",
4
4
  "description": "Core HazelJS framework - Dependency injection, routing, decorators, and base functionality",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -63,5 +63,5 @@
63
63
  "url": "https://github.com/hazeljs/hazel-js/issues"
64
64
  },
65
65
  "homepage": "https://hazeljs.com",
66
- "gitHead": "24092246c221bc5b4437be1a8661cd07c3445cdf"
66
+ "gitHead": "0c26c56bb66a10ab8e909c441ceeafaabc3786f3"
67
67
  }