@moostjs/event-http 0.5.33 → 0.6.1

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 CHANGED
@@ -29,13 +29,77 @@ You can also provide a name for your project:
29
29
  npm create moost my-web-app -- --http
30
30
  ```
31
31
 
32
- This command will initiate a setup tool that will guide you through the project initialization process. It will prompt you to make certain choices such as:
32
+ This command will initiate a setup tool that will guide you through the project initialization process. It will prompt you to configure:
33
33
 
34
- - Whether you want to integrate eslint and prettier.
35
- - Which bundler you prefer to use: esbuild or rollup.
34
+ - Project and package name.
35
+ - Whether to include a Moost Workflows example.
36
+ - Whether to add do-me-lint (smart eslint installer).
37
+
38
+ ## Auth Guards
39
+
40
+ Declarative authentication guards with automatic Swagger/OpenAPI security scheme discovery.
41
+
42
+ ### Functional API
43
+
44
+ ```ts
45
+ import { Authenticate, defineAuthGuard, HttpError } from '@moostjs/event-http'
46
+
47
+ const jwtGuard = defineAuthGuard({ bearer: { format: 'JWT' } }, (transports) => {
48
+ if (!transports.bearer) throw new HttpError(401, 'Missing token')
49
+ // verify and return user info
50
+ })
51
+
52
+ @Authenticate(jwtGuard)
53
+ @Controller('users')
54
+ class UsersController { ... }
55
+ ```
56
+
57
+ ### Class-based API
58
+
59
+ ```ts
60
+ import { AuthGuard, Authenticate, HttpError } from '@moostjs/event-http'
61
+ import { Injectable } from 'moost'
62
+
63
+ @Injectable()
64
+ class JwtGuard extends AuthGuard<{ bearer: { format: 'JWT' } }> {
65
+ static transports = { bearer: { format: 'JWT' } } as const
66
+
67
+ handle(transports: { bearer: string }) {
68
+ if (!transports.bearer) throw new HttpError(401, 'Missing token')
69
+ }
70
+ }
71
+
72
+ @Authenticate(JwtGuard)
73
+ @Controller('users')
74
+ class UsersController { ... }
75
+ ```
76
+
77
+ Supported transports: `bearer`, `basic`, `apiKey` (header/query/cookie), `cookie`.
36
78
 
37
79
  ## [Official Documentation](https://moost.org/webapp/)
38
80
 
81
+ ## AI Agent Skills
82
+
83
+ This package ships skills for AI coding agents (Claude Code, Cursor, Windsurf, Codex, OpenCode). After installing `@moostjs/event-http`, set up the skills:
84
+
85
+ ```bash
86
+ # Project-local (recommended — version-locked, commits with your repo)
87
+ npx moostjs-event-http-skill
88
+
89
+ # Global (available across all your projects)
90
+ npx moostjs-event-http-skill --global
91
+ ```
92
+
93
+ To auto-install skills on `npm install`, add to your `package.json`:
94
+
95
+ ```json
96
+ {
97
+ "scripts": {
98
+ "postinstall": "moostjs-event-http-skill --postinstall"
99
+ }
100
+ }
101
+ ```
102
+
39
103
  ## Contributing
40
104
 
41
105
  We are excited to welcome contributors who are passionate about improving Moostjs. No matter your level of experience, your unique perspective and skills can make valuable contributions to our growing community.
package/dist/index.cjs CHANGED
@@ -21,44 +21,205 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
 
23
23
  //#endregion
24
- const moost = __toESM(require("moost"));
25
24
  const __wooksjs_event_core = __toESM(require("@wooksjs/event-core"));
26
25
  const __wooksjs_event_http = __toESM(require("@wooksjs/event-http"));
26
+ const moost = __toESM(require("moost"));
27
27
  const __wooksjs_http_body = __toESM(require("@wooksjs/http-body"));
28
28
  const __prostojs_infact = __toESM(require("@prostojs/infact"));
29
29
  const http = __toESM(require("http"));
30
30
  const https = __toESM(require("https"));
31
31
 
32
+ //#region packages/event-http/src/auth-guard.ts
33
+ function _define_property$1(obj, key, value) {
34
+ if (key in obj) Object.defineProperty(obj, key, {
35
+ value,
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true
39
+ });
40
+ else obj[key] = value;
41
+ return obj;
42
+ }
43
+ function _ts_decorate(decorators, target, key, desc) {
44
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
45
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
46
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
47
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
48
+ }
49
+ function _ts_metadata(k, v) {
50
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
51
+ }
52
+ function _ts_param(paramIndex, decorator) {
53
+ return function(target, key) {
54
+ decorator(target, key, paramIndex);
55
+ };
56
+ }
57
+ /** Extracts auth credentials from the current request based on transport declarations. Throws 401 if none found. */ function extractTransports(declaration) {
58
+ const ctx = (0, __wooksjs_event_core.current)();
59
+ const result = {};
60
+ let found = false;
61
+ if (declaration.bearer) {
62
+ const auth = (0, __wooksjs_event_http.useAuthorization)(ctx);
63
+ if (auth.is("bearer")) {
64
+ result.bearer = auth.credentials();
65
+ found = true;
66
+ }
67
+ }
68
+ if (declaration.basic) {
69
+ const auth = (0, __wooksjs_event_http.useAuthorization)(ctx);
70
+ if (auth.is("basic")) {
71
+ result.basic = auth.basicCredentials();
72
+ found = true;
73
+ }
74
+ }
75
+ if (declaration.cookie) {
76
+ const { getCookie } = (0, __wooksjs_event_http.useCookies)(ctx);
77
+ const val = getCookie(declaration.cookie.name);
78
+ if (val) {
79
+ result.cookie = val;
80
+ found = true;
81
+ }
82
+ }
83
+ if (declaration.apiKey) {
84
+ const { name, in: location } = declaration.apiKey;
85
+ if (location === "header") {
86
+ const headers = (0, __wooksjs_event_http.useHeaders)(ctx);
87
+ if (headers[name.toLowerCase()]) {
88
+ result.apiKey = headers[name.toLowerCase()];
89
+ found = true;
90
+ }
91
+ } else if (location === "query") {
92
+ const { params } = (0, __wooksjs_event_http.useUrlParams)(ctx);
93
+ const val = params().get(name);
94
+ if (val) {
95
+ result.apiKey = String(val);
96
+ found = true;
97
+ }
98
+ } else if (location === "cookie") {
99
+ const { getCookie } = (0, __wooksjs_event_http.useCookies)(ctx);
100
+ const val = getCookie(name);
101
+ if (val) {
102
+ result.apiKey = val;
103
+ found = true;
104
+ }
105
+ }
106
+ }
107
+ if (!found) throw new __wooksjs_event_http.HttpError(401, "No authentication credentials provided");
108
+ return result;
109
+ }
110
+ /**
111
+ * Creates a functional auth guard interceptor.
112
+ * Extracts credentials from declared transports and passes them to the handler.
113
+ * Return a value from the handler to short-circuit with that response.
114
+ */ function defineAuthGuard(transports, handler) {
115
+ const def = (0, moost.defineBeforeInterceptor)((reply) => {
116
+ const extracted = extractTransports(transports);
117
+ const result = handler(extracted);
118
+ if (result !== null && result !== void 0 && typeof result.then === "function") return result.then((r) => {
119
+ if (r !== void 0) reply(r);
120
+ return void 0;
121
+ });
122
+ if (result !== void 0) reply(result);
123
+ }, moost.TInterceptorPriority.GUARD);
124
+ return Object.assign(def, { __authTransports: transports });
125
+ }
126
+ var AuthGuard = class {
127
+ __intercept(reply) {
128
+ const ctor = this.constructor;
129
+ const extracted = extractTransports(ctor.transports);
130
+ const result = this.handle(extracted);
131
+ if (result !== null && result !== void 0 && typeof result.then === "function") return result.then((r) => {
132
+ if (r !== void 0) reply(r);
133
+ return void 0;
134
+ });
135
+ if (result !== void 0) reply(result);
136
+ }
137
+ };
138
+ _define_property$1(AuthGuard, "transports", void 0);
139
+ _define_property$1(AuthGuard, "priority", moost.TInterceptorPriority.GUARD);
140
+ _ts_decorate([
141
+ (0, moost.Before)(),
142
+ _ts_param(0, (0, moost.Overtake)()),
143
+ _ts_metadata("design:type", Function),
144
+ _ts_metadata("design:paramtypes", [typeof TOvertakeFn === "undefined" ? Object : TOvertakeFn]),
145
+ _ts_metadata("design:returntype", void 0)
146
+ ], AuthGuard.prototype, "__intercept", null);
147
+ AuthGuard = _ts_decorate([(0, moost.Interceptor)(moost.TInterceptorPriority.GUARD)], AuthGuard);
148
+ /**
149
+ * Registers an auth guard as an interceptor and stores its transport
150
+ * declarations in metadata for swagger auto-discovery.
151
+ *
152
+ * Accepts either a functional guard from `defineAuthGuard()` or a
153
+ * class-based guard extending `AuthGuard`.
154
+ */ function Authenticate(handler) {
155
+ const mate = (0, moost.getMoostMate)();
156
+ const isClass = typeof handler === "function";
157
+ const transports = isClass ? handler.transports : handler.__authTransports;
158
+ const priority = isClass ? handler.priority : handler.priority || moost.TInterceptorPriority.GUARD;
159
+ const name = isClass ? handler.name : "AuthGuard";
160
+ return mate.apply(mate.decorate("interceptors", {
161
+ handler,
162
+ priority,
163
+ name
164
+ }, true), mate.decorate("authTransports", transports));
165
+ }
166
+
167
+ //#endregion
32
168
  //#region packages/event-http/src/decorators/http-method.decorator.ts
33
- function HttpMethod(method, path) {
169
+ /** Base decorator for registering an HTTP route handler with an explicit method. */ function HttpMethod(method, path) {
34
170
  return (0, moost.getMoostMate)().decorate("handlers", {
35
171
  method,
36
172
  path,
37
173
  type: "HTTP"
38
174
  }, true);
39
175
  }
40
- const All = (path) => HttpMethod("*", path);
41
- const Get = (path) => HttpMethod("GET", path);
42
- const Post = (path) => HttpMethod("POST", path);
43
- const Put = (path) => HttpMethod("PUT", path);
44
- const Delete = (path) => HttpMethod("DELETE", path);
45
- const Patch = (path) => HttpMethod("PATCH", path);
176
+ /** Register a catch-all route handler matching any HTTP method. */ const All = (path) => HttpMethod("*", path);
177
+ /** Register a GET route handler. */ const Get = (path) => HttpMethod("GET", path);
178
+ /** Register a POST route handler. */ const Post = (path) => HttpMethod("POST", path);
179
+ /** Register a PUT route handler. */ const Put = (path) => HttpMethod("PUT", path);
180
+ /** Register a DELETE route handler. */ const Delete = (path) => HttpMethod("DELETE", path);
181
+ /** Register a PATCH route handler. */ const Patch = (path) => HttpMethod("PATCH", path);
182
+ /**
183
+ * Register an UPGRADE route handler for WebSocket upgrade requests.
184
+ *
185
+ * Use together with `WooksWs` (injected via DI) to complete the handshake:
186
+ * ```ts
187
+ * @Upgrade('/ws')
188
+ * handleUpgrade(ws: WooksWs) {
189
+ * return ws.upgrade()
190
+ * }
191
+ * ```
192
+ */ const Upgrade = (path) => HttpMethod("UPGRADE", path);
46
193
 
47
194
  //#endregion
48
195
  //#region packages/event-http/src/decorators/resolve.decorator.ts
196
+ function createHook(getter, setter) {
197
+ return new Proxy({}, {
198
+ get: (_target, prop) => prop === "value" ? getter() : void 0,
199
+ set: (_target, prop, v) => {
200
+ if (prop === "value") setter(v);
201
+ return true;
202
+ }
203
+ });
204
+ }
49
205
  /**
50
206
  * Hook to the Response Status
51
207
  * @decorator
52
208
  * @paramType TStatusHook
53
209
  */ const StatusHook = () => (0, moost.Resolve)((metas, level) => {
54
- const hook = (0, __wooksjs_event_http.useStatus)();
55
- if (level === "PARAM") return hook;
210
+ const response = (0, __wooksjs_event_http.useResponse)();
211
+ if (level === "PARAM") return createHook(() => response.status, (v) => {
212
+ response.status = v;
213
+ });
56
214
  if (level === "PROP" && metas.instance && metas.key) {
57
215
  const initialValue = metas.instance[metas.key];
58
- (0, __wooksjs_event_core.attachHook)(metas.instance, {
59
- get: () => hook.value,
60
- set: (v) => hook.value = v
61
- }, metas.key);
216
+ Object.defineProperty(metas.instance, metas.key, {
217
+ get: () => response.status,
218
+ set: (v) => {
219
+ response.status = v;
220
+ },
221
+ configurable: true
222
+ });
62
223
  return typeof initialValue === "number" ? initialValue : 200;
63
224
  }
64
225
  }, "statusCode");
@@ -68,14 +229,15 @@ const Patch = (path) => HttpMethod("PATCH", path);
68
229
  * @param name - header name
69
230
  * @paramType THeaderHook
70
231
  */ const HeaderHook = (name) => (0, moost.Resolve)((metas, level) => {
71
- const hook = (0, __wooksjs_event_http.useSetHeader)(name);
72
- if (level === "PARAM") return hook;
232
+ const response = (0, __wooksjs_event_http.useResponse)();
233
+ if (level === "PARAM") return createHook(() => response.getHeader(name), (v) => response.setHeader(name, v));
73
234
  if (level === "PROP" && metas.instance && metas.key) {
74
235
  const initialValue = metas.instance[metas.key];
75
- (0, __wooksjs_event_core.attachHook)(metas.instance, {
76
- get: () => hook.value,
77
- set: (v) => hook.value = v
78
- }, metas.key);
236
+ Object.defineProperty(metas.instance, metas.key, {
237
+ get: () => response.getHeader(name),
238
+ set: (v) => response.setHeader(name, v),
239
+ configurable: true
240
+ });
79
241
  return typeof initialValue === "string" ? initialValue : "";
80
242
  }
81
243
  }, name);
@@ -85,14 +247,15 @@ const Patch = (path) => HttpMethod("PATCH", path);
85
247
  * @param name - cookie name
86
248
  * @paramType TCookieHook
87
249
  */ const CookieHook = (name) => (0, moost.Resolve)((metas, level) => {
88
- const hook = (0, __wooksjs_event_http.useSetCookie)(name);
89
- if (level === "PARAM") return hook;
250
+ const response = (0, __wooksjs_event_http.useResponse)();
251
+ if (level === "PARAM") return createHook(() => response.getCookie(name)?.value, (v) => response.setCookie(name, v ?? ""));
90
252
  if (level === "PROP" && metas.instance && metas.key) {
91
253
  const initialValue = metas.instance[metas.key];
92
- (0, __wooksjs_event_core.attachHook)(metas.instance, {
93
- get: () => hook.value,
94
- set: (v) => hook.value = v
95
- }, metas.key);
254
+ Object.defineProperty(metas.instance, metas.key, {
255
+ get: () => response.getCookie(name)?.value,
256
+ set: (v) => response.setCookie(name, v ?? ""),
257
+ configurable: true
258
+ });
96
259
  return typeof initialValue === "string" ? initialValue : "";
97
260
  }
98
261
  }, name);
@@ -102,17 +265,20 @@ const Patch = (path) => HttpMethod("PATCH", path);
102
265
  * @param name - cookie name
103
266
  * @paramType TCookieAttributes
104
267
  */ const CookieAttrsHook = (name) => (0, moost.Resolve)((metas, level) => {
105
- const hook = (0, __wooksjs_event_http.useSetCookie)(name);
106
- if (level === "PARAM") return (0, __wooksjs_event_core.attachHook)({}, {
107
- get: () => hook.attrs,
108
- set: (v) => hook.attrs = v
109
- });
268
+ const response = (0, __wooksjs_event_http.useResponse)();
269
+ const getAttrs = () => response.getCookie(name)?.attrs;
270
+ const setAttrs = (v) => {
271
+ const existing = response.getCookie(name);
272
+ response.setCookie(name, existing?.value ?? "", v);
273
+ };
274
+ if (level === "PARAM") return createHook(getAttrs, setAttrs);
110
275
  if (level === "PROP" && metas.instance && metas.key) {
111
276
  const initialValue = metas.instance[metas.key];
112
- (0, __wooksjs_event_core.attachHook)(metas.instance, {
113
- get: () => hook.attrs,
114
- set: (v) => hook.attrs = v
115
- }, metas.key);
277
+ Object.defineProperty(metas.instance, metas.key, {
278
+ get: getAttrs,
279
+ set: setAttrs,
280
+ configurable: true
281
+ });
116
282
  return typeof initialValue === "object" ? initialValue : {};
117
283
  }
118
284
  }, name);
@@ -125,11 +291,11 @@ const Patch = (path) => HttpMethod("PATCH", path);
125
291
  return (0, moost.Resolve)(() => {
126
292
  const auth = (0, __wooksjs_event_http.useAuthorization)();
127
293
  switch (name) {
128
- case "username": return auth.isBasic() ? auth.basicCredentials()?.username : void 0;
129
- case "password": return auth.isBasic() ? auth.basicCredentials()?.password : void 0;
130
- case "bearer": return auth.isBearer() ? auth.authorization : void 0;
131
- case "raw": return auth.authRawCredentials();
132
- case "type": return auth.authType();
294
+ case "username": return auth.is("basic") ? auth.basicCredentials()?.username : void 0;
295
+ case "password": return auth.is("basic") ? auth.basicCredentials()?.password : void 0;
296
+ case "bearer": return auth.is("bearer") ? auth.authorization : void 0;
297
+ case "raw": return auth.credentials();
298
+ case "type": return auth.type();
133
299
  default: return void 0;
134
300
  }
135
301
  }, "authorization");
@@ -162,13 +328,13 @@ const Patch = (path) => HttpMethod("PATCH", path);
162
328
  const isItem = !!name;
163
329
  const _name = isItem ? name : "Query";
164
330
  return (0, moost.getMoostMate)().apply((0, moost.getMoostMate)().decorate("paramSource", isItem ? "QUERY_ITEM" : "QUERY"), (0, moost.getMoostMate)().decorate("paramName", _name), (0, moost.Resolve)(() => {
165
- const { jsonSearchParams, urlSearchParams } = (0, __wooksjs_event_http.useSearchParams)();
331
+ const { toJson, params } = (0, __wooksjs_event_http.useUrlParams)();
166
332
  if (isItem) {
167
- const p = urlSearchParams();
333
+ const p = params();
168
334
  const value = p.get(name);
169
335
  return value === null ? void 0 : value;
170
336
  }
171
- const json = jsonSearchParams();
337
+ const json = toJson();
172
338
  return Object.keys(json).length > 0 ? json : void 0;
173
339
  }, _name));
174
340
  }
@@ -191,7 +357,7 @@ const Patch = (path) => HttpMethod("PATCH", path);
191
357
  * @decorator
192
358
  * @paramType IncomingMessage
193
359
  */ function Req() {
194
- return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useRequest)().rawRequest, "request");
360
+ return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useRequest)().raw, "request");
195
361
  }
196
362
  /**
197
363
  * Get Raw Response Instance
@@ -199,7 +365,7 @@ const Patch = (path) => HttpMethod("PATCH", path);
199
365
  * @param opts (optional) { passthrough: boolean }
200
366
  * @paramType ServerResponse
201
367
  */ function Res(opts) {
202
- return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useResponse)().rawResponse(opts), "response");
368
+ return (0, moost.Resolve)(() => (0, __wooksjs_event_http.useResponse)().getRawRes(opts?.passthrough), "response");
203
369
  }
204
370
  /**
205
371
  * Get Request Unique Identificator (UUID)
@@ -240,17 +406,14 @@ const Patch = (path) => HttpMethod("PATCH", path);
240
406
  //#endregion
241
407
  //#region packages/event-http/src/decorators/set.decorator.ts
242
408
  const setHeaderInterceptor = (name, value, opts) => {
243
- const fn = (_before, after, onError) => {
244
- const h = (0, __wooksjs_event_http.useSetHeader)(name);
245
- const status = (0, __wooksjs_event_http.useStatus)();
246
- const cb = () => {
247
- if ((!h.value || opts?.force) && (!opts?.status || opts.status === status.value)) h.value = value;
248
- };
249
- if (opts?.when !== "error") after(cb);
250
- if (opts?.when === "always" || opts?.when === "error") onError(cb);
409
+ const cb = () => {
410
+ const response = (0, __wooksjs_event_http.useResponse)();
411
+ if ((!response.getHeader(name) || opts?.force) && (!opts?.status || opts.status === response.status)) response.setHeader(name, value);
251
412
  };
252
- fn.priority = moost.TInterceptorPriority.AFTER_ALL;
253
- return fn;
413
+ const def = { priority: moost.TInterceptorPriority.AFTER_ALL };
414
+ if (opts?.when !== "error") def.after = cb;
415
+ if (opts?.when === "always" || opts?.when === "error") def.error = cb;
416
+ return def;
254
417
  };
255
418
  /**
256
419
  * Set Header for Request Handler
@@ -291,16 +454,13 @@ const setHeaderInterceptor = (name, value, opts) => {
291
454
  */ function SetHeader(...args) {
292
455
  return (0, moost.Intercept)(setHeaderInterceptor(...args));
293
456
  }
294
- const setCookieInterceptor = (name, value, attrs) => {
295
- const fn = (before, after) => {
296
- const { setCookie, getCookie } = (0, __wooksjs_event_http.useSetCookies)();
297
- after(() => {
298
- if (!getCookie(name)) setCookie(name, value, attrs);
299
- });
300
- };
301
- fn.priority = moost.TInterceptorPriority.AFTER_ALL;
302
- return fn;
303
- };
457
+ const setCookieInterceptor = (name, value, attrs) => ({
458
+ after() {
459
+ const response = (0, __wooksjs_event_http.useResponse)();
460
+ if (!response.getCookie(name)) response.setCookie(name, value, attrs);
461
+ },
462
+ priority: moost.TInterceptorPriority.AFTER_ALL
463
+ });
304
464
  /**
305
465
  * Set Cookie for Request Handler
306
466
  * ```ts
@@ -324,11 +484,12 @@ const setCookieInterceptor = (name, value, attrs) => {
324
484
  */ function SetCookie(...args) {
325
485
  return (0, moost.Intercept)(setCookieInterceptor(...args));
326
486
  }
327
- const setStatusInterceptor = (code, opts) => (0, moost.defineInterceptorFn)((before, after) => {
328
- const status = (0, __wooksjs_event_http.useStatus)();
329
- after(() => {
330
- if (!status.isDefined || opts?.force) status.value = code;
331
- });
487
+ const setStatusInterceptor = (code, opts) => ({
488
+ after() {
489
+ const response = (0, __wooksjs_event_http.useResponse)();
490
+ if (!response.status || opts?.force) response.status = code;
491
+ },
492
+ priority: moost.TInterceptorPriority.AFTER_ALL
332
493
  });
333
494
  /**
334
495
  * Set Response Status for Request Handler
@@ -358,24 +519,24 @@ const setStatusInterceptor = (code, opts) => (0, moost.defineInterceptorFn)((bef
358
519
  * Creates an interceptor that sets the maximum allowed inflated body size in bytes.
359
520
  *
360
521
  * @param n - Maximum body size in bytes after decompression.
361
- * @returns Interceptor function to enforce the limit.
362
- */ const globalBodySizeLimit = (n) => (0, moost.defineInterceptorFn)(() => {
522
+ * @returns Interceptor def to enforce the limit.
523
+ */ const globalBodySizeLimit = (n) => (0, moost.defineBeforeInterceptor)(() => {
363
524
  (0, __wooksjs_event_http.useRequest)().setMaxInflated(n);
364
525
  }, moost.TInterceptorPriority.BEFORE_ALL);
365
526
  /**
366
527
  * Creates an interceptor that sets the maximum allowed compressed body size in bytes.
367
528
  *
368
529
  * @param n - Maximum body size in bytes before decompression.
369
- * @returns Interceptor function to enforce the limit.
370
- */ const globalCompressedBodySizeLimit = (n) => (0, moost.defineInterceptorFn)(() => {
530
+ * @returns Interceptor def to enforce the limit.
531
+ */ const globalCompressedBodySizeLimit = (n) => (0, moost.defineBeforeInterceptor)(() => {
371
532
  (0, __wooksjs_event_http.useRequest)().setMaxCompressed(n);
372
533
  }, moost.TInterceptorPriority.BEFORE_ALL);
373
534
  /**
374
535
  * Creates an interceptor that sets the timeout for reading the request body.
375
536
  *
376
537
  * @param n - Timeout in milliseconds.
377
- * @returns Interceptor function to enforce the timeout.
378
- */ const globalBodyReadTimeoutMs = (n) => (0, moost.defineInterceptorFn)(() => {
538
+ * @returns Interceptor def to enforce the timeout.
539
+ */ const globalBodyReadTimeoutMs = (n) => (0, moost.defineBeforeInterceptor)(() => {
379
540
  (0, __wooksjs_event_http.useRequest)().setReadTimeoutMs(n);
380
541
  }, moost.TInterceptorPriority.BEFORE_ALL);
381
542
  /**
@@ -467,23 +628,24 @@ const CONTEXT_TYPE = "HTTP";
467
628
  if (handler.type !== "HTTP") continue;
468
629
  const httpPath = handler.path;
469
630
  const path = typeof httpPath === "string" ? httpPath : typeof opts.method === "string" ? opts.method : "";
470
- const targetPath = `${`${opts.prefix || ""}/${path}`.replace(/\/\/+/g, "/")}${path.endsWith("//") ? "/" : ""}`;
631
+ const targetPath = `${`${opts.prefix || ""}/${path}`.replaceAll(/\/\/+/g, "/")}${path.endsWith("//") ? "/" : ""}`;
471
632
  fn = (0, moost.defineMoostEventHandler)({
472
633
  contextType: CONTEXT_TYPE,
473
634
  loggerTitle: LOGGER_TITLE,
474
635
  getIterceptorHandler: opts.getIterceptorHandler,
475
636
  getControllerInstance: opts.getInstance,
476
637
  controllerMethod: opts.method,
638
+ controllerName: opts.controllerName,
477
639
  resolveArgs: opts.resolveArgs,
478
640
  manualUnscope: true,
479
641
  hooks: { init: ({ unscope }) => {
480
- const { rawRequest } = (0, __wooksjs_event_http.useRequest)();
481
- rawRequest.on("end", unscope);
642
+ const { raw } = (0, __wooksjs_event_http.useRequest)();
643
+ raw.on("end", unscope);
482
644
  } },
483
645
  targetPath,
484
646
  handlerType: handler.type
485
647
  });
486
- const routerBinding = this.httpApp.on(handler.method, targetPath, fn);
648
+ const routerBinding = handler.method === "UPGRADE" ? this.httpApp.upgrade(targetPath, fn) : this.httpApp.on(handler.method, targetPath, fn);
487
649
  const { getPath: pathBuilder } = routerBinding;
488
650
  const methodMeta = (0, moost.getMoostMate)().read(opts.fakeInstance, opts.method) || {};
489
651
  const id = methodMeta.id || opts.method;
@@ -509,11 +671,11 @@ const CONTEXT_TYPE = "HTTP";
509
671
  _define_property(this, "httpApp", void 0);
510
672
  _define_property(this, "pathBuilders", {});
511
673
  _define_property(this, "moost", void 0);
512
- __wooksjs_event_http.HttpErrorRenderer.registerFramework({
513
- image: "https://moost.org/moost-full-logo.png",
674
+ __wooksjs_event_http.WooksHttpResponse.registerFramework({
675
+ image: "https://moost.org/moost-full-logo.svg",
514
676
  link: "https://moost.org/",
515
677
  poweredBy: "moostjs",
516
- version: "0.5.32"
678
+ version: "0.6.0"
517
679
  });
518
680
  if (httpApp && httpApp instanceof __wooksjs_event_http.WooksHttp) this.httpApp = httpApp;
519
681
  else if (httpApp) this.httpApp = (0, __wooksjs_event_http.createHttpApp)({
@@ -526,6 +688,13 @@ const CONTEXT_TYPE = "HTTP";
526
688
 
527
689
  //#endregion
528
690
  exports.All = All;
691
+ Object.defineProperty(exports, 'AuthGuard', {
692
+ enumerable: true,
693
+ get: function () {
694
+ return AuthGuard;
695
+ }
696
+ });
697
+ exports.Authenticate = Authenticate;
529
698
  exports.Authorization = Authorization;
530
699
  exports.Body = Body;
531
700
  exports.BodyReadTimeoutMs = BodyReadTimeoutMs;
@@ -561,10 +730,19 @@ exports.SetCookie = SetCookie;
561
730
  exports.SetHeader = SetHeader;
562
731
  exports.SetStatus = SetStatus;
563
732
  exports.StatusHook = StatusHook;
733
+ exports.Upgrade = Upgrade;
564
734
  exports.Url = Url;
735
+ exports.defineAuthGuard = defineAuthGuard;
736
+ exports.extractTransports = extractTransports;
565
737
  exports.globalBodyReadTimeoutMs = globalBodyReadTimeoutMs;
566
738
  exports.globalBodySizeLimit = globalBodySizeLimit;
567
739
  exports.globalCompressedBodySizeLimit = globalCompressedBodySizeLimit;
740
+ Object.defineProperty(exports, 'httpKind', {
741
+ enumerable: true,
742
+ get: function () {
743
+ return __wooksjs_event_http.httpKind;
744
+ }
745
+ });
568
746
  Object.defineProperty(exports, 'useHttpContext', {
569
747
  enumerable: true,
570
748
  get: function () {