@moostjs/event-http 0.6.1 → 0.6.2

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/dist/index.cjs CHANGED
@@ -193,7 +193,7 @@ AuthGuard = _ts_decorate([(0, moost.Interceptor)(moost.TInterceptorPriority.GUAR
193
193
 
194
194
  //#endregion
195
195
  //#region packages/event-http/src/decorators/resolve.decorator.ts
196
- function createHook(getter, setter) {
196
+ function createRef(getter, setter) {
197
197
  return new Proxy({}, {
198
198
  get: (_target, prop) => prop === "value" ? getter() : void 0,
199
199
  set: (_target, prop, v) => {
@@ -203,12 +203,12 @@ function createHook(getter, setter) {
203
203
  });
204
204
  }
205
205
  /**
206
- * Hook to the Response Status
206
+ * Ref to the Response Status
207
207
  * @decorator
208
- * @paramType TStatusHook
209
- */ const StatusHook = () => (0, moost.Resolve)((metas, level) => {
208
+ * @paramType TStatusRef
209
+ */ const StatusRef = () => (0, moost.Resolve)((metas, level) => {
210
210
  const response = (0, __wooksjs_event_http.useResponse)();
211
- if (level === "PARAM") return createHook(() => response.status, (v) => {
211
+ if (level === "PARAM") return createRef(() => response.status, (v) => {
212
212
  response.status = v;
213
213
  });
214
214
  if (level === "PROP" && metas.instance && metas.key) {
@@ -224,13 +224,13 @@ function createHook(getter, setter) {
224
224
  }
225
225
  }, "statusCode");
226
226
  /**
227
- * Hook to the Response Header
227
+ * Ref to the Response Header
228
228
  * @decorator
229
229
  * @param name - header name
230
- * @paramType THeaderHook
231
- */ const HeaderHook = (name) => (0, moost.Resolve)((metas, level) => {
230
+ * @paramType THeaderRef
231
+ */ const HeaderRef = (name) => (0, moost.Resolve)((metas, level) => {
232
232
  const response = (0, __wooksjs_event_http.useResponse)();
233
- if (level === "PARAM") return createHook(() => response.getHeader(name), (v) => response.setHeader(name, v));
233
+ if (level === "PARAM") return createRef(() => response.getHeader(name), (v) => response.setHeader(name, v));
234
234
  if (level === "PROP" && metas.instance && metas.key) {
235
235
  const initialValue = metas.instance[metas.key];
236
236
  Object.defineProperty(metas.instance, metas.key, {
@@ -242,13 +242,13 @@ function createHook(getter, setter) {
242
242
  }
243
243
  }, name);
244
244
  /**
245
- * Hook to the Response Cookie
245
+ * Ref to the Response Cookie
246
246
  * @decorator
247
247
  * @param name - cookie name
248
- * @paramType TCookieHook
249
- */ const CookieHook = (name) => (0, moost.Resolve)((metas, level) => {
248
+ * @paramType TCookieRef
249
+ */ const CookieRef = (name) => (0, moost.Resolve)((metas, level) => {
250
250
  const response = (0, __wooksjs_event_http.useResponse)();
251
- if (level === "PARAM") return createHook(() => response.getCookie(name)?.value, (v) => response.setCookie(name, v ?? ""));
251
+ if (level === "PARAM") return createRef(() => response.getCookie(name)?.value, (v) => response.setCookie(name, v ?? ""));
252
252
  if (level === "PROP" && metas.instance && metas.key) {
253
253
  const initialValue = metas.instance[metas.key];
254
254
  Object.defineProperty(metas.instance, metas.key, {
@@ -260,18 +260,18 @@ function createHook(getter, setter) {
260
260
  }
261
261
  }, name);
262
262
  /**
263
- * Hook to the Response Cookie Attributes
263
+ * Ref to the Response Cookie Attributes
264
264
  * @decorator
265
265
  * @param name - cookie name
266
266
  * @paramType TCookieAttributes
267
- */ const CookieAttrsHook = (name) => (0, moost.Resolve)((metas, level) => {
267
+ */ const CookieAttrsRef = (name) => (0, moost.Resolve)((metas, level) => {
268
268
  const response = (0, __wooksjs_event_http.useResponse)();
269
- const getAttrs = () => response.getCookie(name)?.attrs;
269
+ const getAttrs = () => response.getCookie(name)?.attrs ?? {};
270
270
  const setAttrs = (v) => {
271
271
  const existing = response.getCookie(name);
272
272
  response.setCookie(name, existing?.value ?? "", v);
273
273
  };
274
- if (level === "PARAM") return createHook(getAttrs, setAttrs);
274
+ if (level === "PARAM") return createRef(getAttrs, setAttrs);
275
275
  if (level === "PROP" && metas.instance && metas.key) {
276
276
  const initialValue = metas.instance[metas.key];
277
277
  Object.defineProperty(metas.instance, metas.key, {
@@ -675,7 +675,7 @@ const CONTEXT_TYPE = "HTTP";
675
675
  image: "https://moost.org/moost-full-logo.svg",
676
676
  link: "https://moost.org/",
677
677
  poweredBy: "moostjs",
678
- version: "0.6.0"
678
+ version: "0.6.1"
679
679
  });
680
680
  if (httpApp && httpApp instanceof __wooksjs_event_http.WooksHttp) this.httpApp = httpApp;
681
681
  else if (httpApp) this.httpApp = (0, __wooksjs_event_http.createHttpApp)({
@@ -701,12 +701,12 @@ exports.BodyReadTimeoutMs = BodyReadTimeoutMs;
701
701
  exports.BodySizeLimit = BodySizeLimit;
702
702
  exports.CompressedBodySizeLimit = CompressedBodySizeLimit;
703
703
  exports.Cookie = Cookie;
704
- exports.CookieAttrsHook = CookieAttrsHook;
705
- exports.CookieHook = CookieHook;
704
+ exports.CookieAttrsRef = CookieAttrsRef;
705
+ exports.CookieRef = CookieRef;
706
706
  exports.Delete = Delete;
707
707
  exports.Get = Get;
708
708
  exports.Header = Header;
709
- exports.HeaderHook = HeaderHook;
709
+ exports.HeaderRef = HeaderRef;
710
710
  Object.defineProperty(exports, 'HttpError', {
711
711
  enumerable: true,
712
712
  get: function () {
@@ -729,7 +729,7 @@ exports.Res = Res;
729
729
  exports.SetCookie = SetCookie;
730
730
  exports.SetHeader = SetHeader;
731
731
  exports.SetStatus = SetStatus;
732
- exports.StatusHook = StatusHook;
732
+ exports.StatusRef = StatusRef;
733
733
  exports.Upgrade = Upgrade;
734
734
  exports.Url = Url;
735
735
  exports.defineAuthGuard = defineAuthGuard;
package/dist/index.d.ts CHANGED
@@ -106,32 +106,32 @@ declare const Patch: (path?: string) => MethodDecorator;
106
106
  declare const Upgrade: (path?: string) => MethodDecorator;
107
107
 
108
108
  /**
109
- * Hook to the Response Status
109
+ * Ref to the Response Status
110
110
  * @decorator
111
- * @paramType TStatusHook
111
+ * @paramType TStatusRef
112
112
  */
113
- declare const StatusHook: () => ParameterDecorator & PropertyDecorator;
113
+ declare const StatusRef: () => ParameterDecorator & PropertyDecorator;
114
114
  /**
115
- * Hook to the Response Header
115
+ * Ref to the Response Header
116
116
  * @decorator
117
117
  * @param name - header name
118
- * @paramType THeaderHook
118
+ * @paramType THeaderRef
119
119
  */
120
- declare const HeaderHook: (name: string) => ParameterDecorator & PropertyDecorator;
120
+ declare const HeaderRef: (name: string) => ParameterDecorator & PropertyDecorator;
121
121
  /**
122
- * Hook to the Response Cookie
122
+ * Ref to the Response Cookie
123
123
  * @decorator
124
124
  * @param name - cookie name
125
- * @paramType TCookieHook
125
+ * @paramType TCookieRef
126
126
  */
127
- declare const CookieHook: (name: string) => ParameterDecorator & PropertyDecorator;
127
+ declare const CookieRef: (name: string) => ParameterDecorator & PropertyDecorator;
128
128
  /**
129
- * Hook to the Response Cookie Attributes
129
+ * Ref to the Response Cookie Attributes
130
130
  * @decorator
131
131
  * @param name - cookie name
132
132
  * @paramType TCookieAttributes
133
133
  */
134
- declare const CookieAttrsHook: (name: string) => ParameterDecorator & PropertyDecorator;
134
+ declare const CookieAttrsRef: (name: string) => ParameterDecorator & PropertyDecorator;
135
135
  /**
136
136
  * Parse Authorisation Header
137
137
  * @decorator
@@ -219,18 +219,18 @@ declare function Body(): MethodDecorator & ClassDecorator & ParameterDecorator &
219
219
  * @paramType Promise<Buffer>
220
220
  */
221
221
  declare function RawBody(): ParameterDecorator & PropertyDecorator;
222
- /** Reactive hook for reading/writing the response status code. */
223
- interface TStatusHook {
222
+ /** Reactive ref for reading/writing the response status code. */
223
+ interface TStatusRef {
224
224
  value: number;
225
225
  }
226
- /** Reactive hook for reading/writing a response header value. */
227
- interface THeaderHook {
226
+ /** Reactive ref for reading/writing a response header value. */
227
+ interface THeaderRef {
228
228
  value: string | string[] | undefined;
229
229
  }
230
230
  /** Partial cookie attributes (all optional). */
231
231
  type TCookieAttributes = Partial<TCookieAttributes$1>;
232
- /** Reactive hook for reading/writing a response cookie. */
233
- interface TCookieHook {
232
+ /** Reactive ref for reading/writing a response cookie. */
233
+ interface TCookieRef {
234
234
  value: string;
235
235
  attrs?: TCookieAttributes;
236
236
  }
@@ -425,5 +425,5 @@ declare class MoostHttp implements TMoostAdapter<THttpHandlerMeta> {
425
425
  bindHandler<T extends object = object>(opts: TMoostAdapterOptions<THttpHandlerMeta, T>): void;
426
426
  }
427
427
 
428
- export { All, AuthGuard, Authenticate, Authorization, Body, BodyReadTimeoutMs, BodySizeLimit, CompressedBodySizeLimit, Cookie, CookieAttrsHook, CookieHook, Delete, Get, Header, HeaderHook, HttpMethod, Ip, IpList, Method, MoostHttp, Patch, Post, Put, Query, RawBody, Req, ReqId, Res, SetCookie, SetHeader, SetStatus, StatusHook, Upgrade, Url, defineAuthGuard, extractTransports, globalBodyReadTimeoutMs, globalBodySizeLimit, globalCompressedBodySizeLimit };
429
- export type { TAuthGuardClass, TAuthGuardDef, TAuthGuardHandler, TAuthTransportApiKey, TAuthTransportBasic, TAuthTransportBearer, TAuthTransportCookie, TAuthTransportDeclaration, TAuthTransportValues, TCookieAttributes, TCookieHook, THeaderHook, THttpHandlerMeta, TStatusHook };
428
+ export { All, AuthGuard, Authenticate, Authorization, Body, BodyReadTimeoutMs, BodySizeLimit, CompressedBodySizeLimit, Cookie, CookieAttrsRef, CookieRef, Delete, Get, Header, HeaderRef, HttpMethod, Ip, IpList, Method, MoostHttp, Patch, Post, Put, Query, RawBody, Req, ReqId, Res, SetCookie, SetHeader, SetStatus, StatusRef, Upgrade, Url, defineAuthGuard, extractTransports, globalBodyReadTimeoutMs, globalBodySizeLimit, globalCompressedBodySizeLimit };
429
+ export type { TAuthGuardClass, TAuthGuardDef, TAuthGuardHandler, TAuthTransportApiKey, TAuthTransportBasic, TAuthTransportBearer, TAuthTransportCookie, TAuthTransportDeclaration, TAuthTransportValues, TCookieAttributes, TCookieRef, THeaderRef, THttpHandlerMeta, TStatusRef };
package/dist/index.mjs CHANGED
@@ -170,7 +170,7 @@ AuthGuard = _ts_decorate([Interceptor(TInterceptorPriority.GUARD)], AuthGuard);
170
170
 
171
171
  //#endregion
172
172
  //#region packages/event-http/src/decorators/resolve.decorator.ts
173
- function createHook(getter, setter) {
173
+ function createRef(getter, setter) {
174
174
  return new Proxy({}, {
175
175
  get: (_target, prop) => prop === "value" ? getter() : void 0,
176
176
  set: (_target, prop, v) => {
@@ -180,12 +180,12 @@ function createHook(getter, setter) {
180
180
  });
181
181
  }
182
182
  /**
183
- * Hook to the Response Status
183
+ * Ref to the Response Status
184
184
  * @decorator
185
- * @paramType TStatusHook
186
- */ const StatusHook = () => Resolve((metas, level) => {
185
+ * @paramType TStatusRef
186
+ */ const StatusRef = () => Resolve((metas, level) => {
187
187
  const response = useResponse();
188
- if (level === "PARAM") return createHook(() => response.status, (v) => {
188
+ if (level === "PARAM") return createRef(() => response.status, (v) => {
189
189
  response.status = v;
190
190
  });
191
191
  if (level === "PROP" && metas.instance && metas.key) {
@@ -201,13 +201,13 @@ function createHook(getter, setter) {
201
201
  }
202
202
  }, "statusCode");
203
203
  /**
204
- * Hook to the Response Header
204
+ * Ref to the Response Header
205
205
  * @decorator
206
206
  * @param name - header name
207
- * @paramType THeaderHook
208
- */ const HeaderHook = (name) => Resolve((metas, level) => {
207
+ * @paramType THeaderRef
208
+ */ const HeaderRef = (name) => Resolve((metas, level) => {
209
209
  const response = useResponse();
210
- if (level === "PARAM") return createHook(() => response.getHeader(name), (v) => response.setHeader(name, v));
210
+ if (level === "PARAM") return createRef(() => response.getHeader(name), (v) => response.setHeader(name, v));
211
211
  if (level === "PROP" && metas.instance && metas.key) {
212
212
  const initialValue = metas.instance[metas.key];
213
213
  Object.defineProperty(metas.instance, metas.key, {
@@ -219,13 +219,13 @@ function createHook(getter, setter) {
219
219
  }
220
220
  }, name);
221
221
  /**
222
- * Hook to the Response Cookie
222
+ * Ref to the Response Cookie
223
223
  * @decorator
224
224
  * @param name - cookie name
225
- * @paramType TCookieHook
226
- */ const CookieHook = (name) => Resolve((metas, level) => {
225
+ * @paramType TCookieRef
226
+ */ const CookieRef = (name) => Resolve((metas, level) => {
227
227
  const response = useResponse();
228
- if (level === "PARAM") return createHook(() => response.getCookie(name)?.value, (v) => response.setCookie(name, v ?? ""));
228
+ if (level === "PARAM") return createRef(() => response.getCookie(name)?.value, (v) => response.setCookie(name, v ?? ""));
229
229
  if (level === "PROP" && metas.instance && metas.key) {
230
230
  const initialValue = metas.instance[metas.key];
231
231
  Object.defineProperty(metas.instance, metas.key, {
@@ -237,18 +237,18 @@ function createHook(getter, setter) {
237
237
  }
238
238
  }, name);
239
239
  /**
240
- * Hook to the Response Cookie Attributes
240
+ * Ref to the Response Cookie Attributes
241
241
  * @decorator
242
242
  * @param name - cookie name
243
243
  * @paramType TCookieAttributes
244
- */ const CookieAttrsHook = (name) => Resolve((metas, level) => {
244
+ */ const CookieAttrsRef = (name) => Resolve((metas, level) => {
245
245
  const response = useResponse();
246
- const getAttrs = () => response.getCookie(name)?.attrs;
246
+ const getAttrs = () => response.getCookie(name)?.attrs ?? {};
247
247
  const setAttrs = (v) => {
248
248
  const existing = response.getCookie(name);
249
249
  response.setCookie(name, existing?.value ?? "", v);
250
250
  };
251
- if (level === "PARAM") return createHook(getAttrs, setAttrs);
251
+ if (level === "PARAM") return createRef(getAttrs, setAttrs);
252
252
  if (level === "PROP" && metas.instance && metas.key) {
253
253
  const initialValue = metas.instance[metas.key];
254
254
  Object.defineProperty(metas.instance, metas.key, {
@@ -652,7 +652,7 @@ const CONTEXT_TYPE = "HTTP";
652
652
  image: "https://moost.org/moost-full-logo.svg",
653
653
  link: "https://moost.org/",
654
654
  poweredBy: "moostjs",
655
- version: "0.6.0"
655
+ version: "0.6.1"
656
656
  });
657
657
  if (httpApp && httpApp instanceof WooksHttp) this.httpApp = httpApp;
658
658
  else if (httpApp) this.httpApp = createHttpApp({
@@ -664,4 +664,4 @@ const CONTEXT_TYPE = "HTTP";
664
664
  };
665
665
 
666
666
  //#endregion
667
- export { All, AuthGuard, Authenticate, Authorization, Body, BodyReadTimeoutMs, BodySizeLimit, CompressedBodySizeLimit, Cookie, CookieAttrsHook, CookieHook, Delete, Get, Header, HeaderHook, HttpError, HttpMethod, Ip, IpList, Method, MoostHttp, Patch, Post, Put, Query, RawBody, Req, ReqId, Res, SetCookie, SetHeader, SetStatus, StatusHook, Upgrade, Url, defineAuthGuard, extractTransports, globalBodyReadTimeoutMs, globalBodySizeLimit, globalCompressedBodySizeLimit, httpKind, useHttpContext };
667
+ export { All, AuthGuard, Authenticate, Authorization, Body, BodyReadTimeoutMs, BodySizeLimit, CompressedBodySizeLimit, Cookie, CookieAttrsRef, CookieRef, Delete, Get, Header, HeaderRef, HttpError, HttpMethod, Ip, IpList, Method, MoostHttp, Patch, Post, Put, Query, RawBody, Req, ReqId, Res, SetCookie, SetHeader, SetStatus, StatusRef, Upgrade, Url, defineAuthGuard, extractTransports, globalBodyReadTimeoutMs, globalBodySizeLimit, globalCompressedBodySizeLimit, httpKind, useHttpContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/event-http",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "@moostjs/event-http",
5
5
  "keywords": [
6
6
  "composables",
@@ -43,17 +43,16 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "@wooksjs/event-http": "^0.7.3",
47
- "@wooksjs/http-body": "^0.7.3"
46
+ "@wooksjs/event-http": "^0.7.4",
47
+ "@wooksjs/http-body": "^0.7.4"
48
48
  },
49
49
  "devDependencies": {
50
50
  "vitest": "3.2.4"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@prostojs/infact": "^0.4.1",
54
- "@prostojs/router": "^0.3.2",
55
- "@wooksjs/event-core": "^0.7.3",
56
- "moost": "^0.6.1"
54
+ "@wooksjs/event-core": "^0.7.4",
55
+ "moost": "^0.6.2"
57
56
  },
58
57
  "scripts": {
59
58
  "pub": "pnpm publish --access public",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: moostjs-event-http
3
- description: Use this skill when working with @moostjs/event-http — to create an HTTP server with MoostHttp adapter, register route handlers with @Get()/@Post()/@Put()/@Delete()/@Patch()/@All(), extract request data with @Query(), @Header(), @Cookie(), @Body(), @RawBody(), @Authorization(), @Url(), @Method(), @Req(), @Res(), @ReqId(), @Ip(), @IpList(), control responses with @SetHeader(), @SetCookie(), @SetStatus(), @StatusHook(), @HeaderHook(), @CookieHook(), @CookieAttrsHook(), throw HTTP errors with HttpError, enforce body limits with @BodySizeLimit()/@CompressedBodySizeLimit()/@BodyReadTimeoutMs(), define auth guards with defineAuthGuard()/AuthGuard/Authenticate, or handle WebSocket upgrades with @Upgrade().
3
+ description: Use this skill when working with @moostjs/event-http — to create an HTTP server with MoostHttp adapter, register route handlers with @Get()/@Post()/@Put()/@Delete()/@Patch()/@All(), extract request data with @Query(), @Header(), @Cookie(), @Body(), @RawBody(), @Authorization(), @Url(), @Method(), @Req(), @Res(), @ReqId(), @Ip(), @IpList(), control responses with @SetHeader(), @SetCookie(), @SetStatus(), @StatusRef(), @HeaderRef(), @CookieRef(), @CookieAttrsRef(), throw HTTP errors with HttpError, enforce body limits with @BodySizeLimit()/@CompressedBodySizeLimit()/@BodyReadTimeoutMs(), define auth guards with defineAuthGuard()/AuthGuard/Authenticate, or handle WebSocket upgrades with @Upgrade().
4
4
  ---
5
5
 
6
6
  # @moostjs/event-http
@@ -25,7 +25,7 @@ Read the domain file that matches the task. Do not load all files — only what
25
25
  // Imports
26
26
  import { MoostHttp, Get, Post, Put, Delete, Patch, All, HttpMethod, Upgrade } from '@moostjs/event-http'
27
27
  import { Query, Header, Cookie, Body, RawBody, Authorization, Url, Method, Req, Res, ReqId, Ip, IpList } from '@moostjs/event-http'
28
- import { SetHeader, SetCookie, SetStatus, StatusHook, HeaderHook, CookieHook, CookieAttrsHook } from '@moostjs/event-http'
28
+ import { SetHeader, SetCookie, SetStatus, StatusRef, HeaderRef, CookieRef, CookieAttrsRef } from '@moostjs/event-http'
29
29
  import { BodySizeLimit, CompressedBodySizeLimit, BodyReadTimeoutMs } from '@moostjs/event-http'
30
30
  import { Authenticate, AuthGuard, defineAuthGuard, HttpError } from '@moostjs/event-http'
31
31
  import { Controller, Param, Params } from 'moost'
@@ -7,9 +7,9 @@
7
7
  Moost provides two styles for response control:
8
8
 
9
9
  1. **Static decorators** (`@SetStatus`, `@SetHeader`, `@SetCookie`) — applied via interceptors at `AFTER_ALL` priority, declarative and fixed
10
- 2. **Dynamic hooks** (`@StatusHook`, `@HeaderHook`, `@CookieHook`, `@CookieAttrsHook`) — Proxy-based reactive bindings, set values programmatically at runtime
10
+ 2. **Dynamic refs** (`@StatusRef`, `@HeaderRef`, `@CookieRef`, `@CookieAttrsRef`) — Proxy-based reactive bindings, set values programmatically at runtime
11
11
 
12
- Both work as method decorators. Hook decorators also work as parameter decorators and property decorators (on `FOR_EVENT`-scoped controllers).
12
+ Both work as method decorators. Ref decorators also work as parameter decorators and property decorators (on `FOR_EVENT`-scoped controllers).
13
13
 
14
14
  ## API Reference
15
15
 
@@ -28,16 +28,16 @@ create() { return { created: true } }
28
28
  @SetStatus(200, { force: true })
29
29
  ```
30
30
 
31
- ### `@StatusHook()`
31
+ ### `@StatusRef()`
32
32
 
33
33
  Dynamic status code control via a `{ value: number }` proxy object.
34
34
 
35
35
  ```ts
36
- import { Get, StatusHook } from '@moostjs/event-http'
37
- import type { TStatusHook } from '@moostjs/event-http'
36
+ import { Get, StatusRef } from '@moostjs/event-http'
37
+ import type { TStatusRef } from '@moostjs/event-http'
38
38
 
39
39
  @Get('process')
40
- process(@StatusHook() status: TStatusHook) {
40
+ process(@StatusRef() status: TStatusRef) {
41
41
  if (someCondition) {
42
42
  status.value = 202
43
43
  return { status: 'processing' }
@@ -52,7 +52,7 @@ Works as a property decorator too:
52
52
  @Injectable('FOR_EVENT')
53
53
  @Controller()
54
54
  class MyController {
55
- @StatusHook()
55
+ @StatusRef()
56
56
  status = 200 // initial value
57
57
 
58
58
  @Get('test')
@@ -90,16 +90,16 @@ Options:
90
90
  @SetHeader('x-error', 'true', { when: 'error' })
91
91
  ```
92
92
 
93
- ### `@HeaderHook(name)`
93
+ ### `@HeaderRef(name)`
94
94
 
95
95
  Dynamic header control via a `{ value: string | string[] | undefined }` proxy.
96
96
 
97
97
  ```ts
98
- import { Get, HeaderHook } from '@moostjs/event-http'
99
- import type { THeaderHook } from '@moostjs/event-http'
98
+ import { Get, HeaderRef } from '@moostjs/event-http'
99
+ import type { THeaderRef } from '@moostjs/event-http'
100
100
 
101
101
  @Get('test')
102
- test(@HeaderHook('x-custom') header: THeaderHook) {
102
+ test(@HeaderRef('x-custom') header: THeaderRef) {
103
103
  header.value = `generated-${Date.now()}`
104
104
  return 'ok'
105
105
  }
@@ -119,31 +119,31 @@ login() { return { ok: true } }
119
119
 
120
120
  Cookie attributes (`TCookieAttributesInput`): `maxAge`, `expires`, `domain`, `path`, `secure`, `httpOnly`, `sameSite`, etc.
121
121
 
122
- ### `@CookieHook(name)`
122
+ ### `@CookieRef(name)`
123
123
 
124
124
  Dynamic cookie value control.
125
125
 
126
126
  ```ts
127
- import { Post, CookieHook } from '@moostjs/event-http'
128
- import type { TCookieHook } from '@moostjs/event-http'
127
+ import { Post, CookieRef } from '@moostjs/event-http'
128
+ import type { TCookieRef } from '@moostjs/event-http'
129
129
 
130
130
  @Post('login')
131
- login(@CookieHook('session') cookie: TCookieHook) {
131
+ login(@CookieRef('session') cookie: TCookieRef) {
132
132
  cookie.value = generateToken()
133
133
  return { ok: true }
134
134
  }
135
135
  ```
136
136
 
137
- ### `@CookieAttrsHook(name)`
137
+ ### `@CookieAttrsRef(name)`
138
138
 
139
139
  Dynamic cookie attributes control.
140
140
 
141
141
  ```ts
142
- import { Post, CookieAttrsHook } from '@moostjs/event-http'
142
+ import { Post, CookieAttrsRef } from '@moostjs/event-http'
143
143
  import type { TCookieAttributes } from '@moostjs/event-http'
144
144
 
145
145
  @Post('login')
146
- login(@CookieAttrsHook('session') attrs: { value: TCookieAttributes }) {
146
+ login(@CookieAttrsRef('session') attrs: { value: TCookieAttributes }) {
147
147
  attrs.value = { maxAge: '1h', httpOnly: true, secure: true }
148
148
  return { ok: true }
149
149
  }
@@ -252,7 +252,7 @@ class ItemController {
252
252
  ```ts
253
253
  @Get('data')
254
254
  @SetHeader('x-cache', 'miss', { when: 'always' })
255
- getData(@HeaderHook('x-cache') cache: THeaderHook) {
255
+ getData(@HeaderRef('x-cache') cache: THeaderRef) {
256
256
  const cached = getFromCache()
257
257
  if (cached) {
258
258
  cache.value = 'hit'
@@ -265,17 +265,17 @@ getData(@HeaderHook('x-cache') cache: THeaderHook) {
265
265
  ## Types
266
266
 
267
267
  ```ts
268
- export interface TStatusHook { value: number }
269
- export interface THeaderHook { value: string | string[] | undefined }
270
- export interface TCookieHook { value: string; attrs?: TCookieAttributes }
268
+ export interface TStatusRef { value: number }
269
+ export interface THeaderRef { value: string | string[] | undefined }
270
+ export interface TCookieRef { value: string; attrs?: TCookieAttributes }
271
271
  export type TCookieAttributes = Partial<TCookieAttributesRequired>
272
272
  ```
273
273
 
274
274
  ## Best Practices
275
275
 
276
276
  - Use `@SetStatus` for fixed status codes (201 for creation, 204 for deletion)
277
- - Use `@StatusHook` when the status depends on runtime logic
278
- - Use `@SetHeader` for static headers, `@HeaderHook` for dynamic ones
277
+ - Use `@StatusRef` when the status depends on runtime logic
278
+ - Use `@SetHeader` for static headers, `@HeaderRef` for dynamic ones
279
279
  - Apply body limits on upload endpoints to prevent abuse
280
280
  - Use global limit interceptors for application-wide defaults
281
281
 
@@ -284,4 +284,4 @@ export type TCookieAttributes = Partial<TCookieAttributesRequired>
284
284
  - `@SetStatus` won't override a status already set (e.g., by an error) unless `{ force: true }` is passed
285
285
  - `@SetCookie` won't overwrite a cookie already set in the response — this prevents accidental overwrites
286
286
  - `@SetHeader` defaults to success-only (`after` interceptor); use `{ when: 'always' }` to include error responses
287
- - Hook decorators use Proxy objects — the `.value` property is reactive, not a plain field
287
+ - Ref decorators use Proxy objects — the `.value` property is reactive, not a plain field