@moostjs/event-http 0.6.52 → 0.7.0
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 +78 -14
- package/dist/index.d.ts +32 -8
- package/dist/index.mjs +62 -16
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ let _wooksjs_http_body = require("@wooksjs/http-body");
|
|
|
6
6
|
let _prostojs_infact = require("@prostojs/infact");
|
|
7
7
|
let http = require("http");
|
|
8
8
|
let https = require("https");
|
|
9
|
+
let net = require("net");
|
|
9
10
|
|
|
10
11
|
//#region packages/event-http/src/auth-guard.ts
|
|
11
12
|
function _define_property$1(obj, key, value) {
|
|
@@ -294,7 +295,10 @@ function createRef(getter, setter) {
|
|
|
294
295
|
return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useCookies)().getCookie(name), `cookie: ${name}`);
|
|
295
296
|
}
|
|
296
297
|
/**
|
|
297
|
-
* Get Query Item value or the whole parsed Query as an object
|
|
298
|
+
* Get Query Item value or the whole parsed Query as an object.
|
|
299
|
+
*
|
|
300
|
+
* Without `name`, resolves the parsed query — `{}` when the request has no query string.
|
|
301
|
+
* With `name`, resolves that item's value, or `undefined` when it is absent.
|
|
298
302
|
* @decorator
|
|
299
303
|
* @param name - query item name (optional)
|
|
300
304
|
* @paramType string | object
|
|
@@ -307,8 +311,7 @@ function createRef(getter, setter) {
|
|
|
307
311
|
const value = params().get(name);
|
|
308
312
|
return value === null ? void 0 : value;
|
|
309
313
|
}
|
|
310
|
-
|
|
311
|
-
return Object.keys(json).length > 0 ? json : void 0;
|
|
314
|
+
return toJson();
|
|
312
315
|
}, _name));
|
|
313
316
|
}
|
|
314
317
|
/**
|
|
@@ -348,16 +351,28 @@ function createRef(getter, setter) {
|
|
|
348
351
|
return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useRequest)().reqId(), "reqId");
|
|
349
352
|
}
|
|
350
353
|
/**
|
|
351
|
-
* Get
|
|
354
|
+
* Get the client IP address.
|
|
355
|
+
*
|
|
356
|
+
* Without arguments it follows the app's `trustProxy` setting (`new MoostHttp({ trustProxy })`):
|
|
357
|
+
* the socket peer when no proxy is trusted (the default), else the right-most untrusted
|
|
358
|
+
* `X-Forwarded-For` / `Forwarded` hop. IPv4-mapped addresses are returned as plain IPv4;
|
|
359
|
+
* `''` when the client is unknown (an in-process `fetch()` without a peer, a malformed
|
|
360
|
+
* forwarding entry from a trusted proxy).
|
|
361
|
+
*
|
|
362
|
+
* @param opts - **Deprecated:** `{ trustProxy: true }` trusts exactly ONE proxy hop (the
|
|
363
|
+
* right-most `X-Forwarded-For` entry, no longer the forgeable left-most one);
|
|
364
|
+
* `{ trustProxy: false }` returns the socket peer. Configure `trustProxy` on `MoostHttp`
|
|
365
|
+
* instead and use `@Ip()`.
|
|
352
366
|
* @decorator
|
|
353
367
|
* @paramType string
|
|
354
368
|
*/ function Ip(opts) {
|
|
355
369
|
return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useRequest)().getIp(opts), "ip");
|
|
356
370
|
}
|
|
357
371
|
/**
|
|
358
|
-
* Get
|
|
372
|
+
* Get the raw address list: the socket peer and every `X-Forwarded-For` entry, unvalidated
|
|
373
|
+
* (client-forgeable — use `@Ip()` for the client address).
|
|
359
374
|
* @decorator
|
|
360
|
-
* @paramType string[]
|
|
375
|
+
* @paramType { remoteIp: string, forwarded: string[] }
|
|
361
376
|
*/ function IpList() {
|
|
362
377
|
return (0, moost.Resolve)(() => (0, _wooksjs_event_http.useRequest)().getIpList(), "ipList");
|
|
363
378
|
}
|
|
@@ -603,15 +618,37 @@ function _define_property(obj, key, value) {
|
|
|
603
618
|
return obj;
|
|
604
619
|
}
|
|
605
620
|
/** Marks the child context of {@link MoostHttp.invoke}. */ const invocationKey = (0, moost.globalKey)("moost-http.invocation");
|
|
621
|
+
/**
|
|
622
|
+
* Releases of queued (pipelined) responses per connection: one socket 'close' listener per
|
|
623
|
+
* connection, however many requests are queued on it.
|
|
624
|
+
*/ const queuedReleases = /* @__PURE__ */ new WeakMap();
|
|
625
|
+
function releaseQueued() {
|
|
626
|
+
const releases = queuedReleases.get(this);
|
|
627
|
+
queuedReleases.delete(this);
|
|
628
|
+
releases?.forEach((release) => release());
|
|
629
|
+
}
|
|
606
630
|
const holdScopeUntilResponseCloses = { init: ({ unscope }) => {
|
|
607
631
|
const ctx = (0, moost.current)();
|
|
608
|
-
|
|
632
|
+
const res = ctx.hasOwn(invocationKey) ? void 0 : (0, _wooksjs_event_http.useResponse)(ctx).getRawRes(true);
|
|
633
|
+
const connection = res && !res.closed ? res.socket ?? res.req?.socket : void 0;
|
|
634
|
+
if (!res || !(connection instanceof net.Socket)) {
|
|
609
635
|
unscope();
|
|
610
636
|
return;
|
|
611
637
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
638
|
+
if (res.socket) {
|
|
639
|
+
res.on("close", unscope);
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
let releases = queuedReleases.get(connection);
|
|
643
|
+
if (!releases) {
|
|
644
|
+
queuedReleases.set(connection, releases = /* @__PURE__ */ new Set());
|
|
645
|
+
connection.once("close", releaseQueued);
|
|
646
|
+
}
|
|
647
|
+
releases.add(unscope);
|
|
648
|
+
res.on("close", () => {
|
|
649
|
+
releases.delete(unscope);
|
|
650
|
+
unscope();
|
|
651
|
+
});
|
|
615
652
|
} };
|
|
616
653
|
const LOGGER_TITLE = "moost-http";
|
|
617
654
|
/**
|
|
@@ -657,9 +694,18 @@ const LOGGER_TITLE = "moost-http";
|
|
|
657
694
|
* argument resolution, pipes, validation, and handler execution.
|
|
658
695
|
*
|
|
659
696
|
* When called from within an existing HTTP context (e.g. during SSR),
|
|
660
|
-
* identity headers (authorization, cookie) are automatically forwarded
|
|
661
|
-
|
|
662
|
-
|
|
697
|
+
* identity headers (authorization, cookie) are automatically forwarded, and the
|
|
698
|
+
* inner request inherits the caller's client (`@Ip()`, protocol, host) and locale.
|
|
699
|
+
*
|
|
700
|
+
* Serving a fetch runtime (Bun, Deno, edge) with no calling request, pass the connection's
|
|
701
|
+
* `peer` — without it the client address is unknown (`@Ip()` is `''`) and an address-based
|
|
702
|
+
* `trustProxy` trusts nothing.
|
|
703
|
+
*
|
|
704
|
+
* @param request - A Web Standard Request.
|
|
705
|
+
* @param peer - `remoteAddress` of the connection (the client, or the proxy in front) and
|
|
706
|
+
* `encrypted` (TLS; default: the URL scheme).
|
|
707
|
+
*/ fetch(request, peer) {
|
|
708
|
+
return this.httpApp.fetch(request, peer);
|
|
663
709
|
}
|
|
664
710
|
/**
|
|
665
711
|
* Convenience wrapper for programmatic route invocation.
|
|
@@ -822,7 +868,7 @@ const LOGGER_TITLE = "moost-http";
|
|
|
822
868
|
image: "https://moost.org/moost-full-logo.svg",
|
|
823
869
|
link: "https://moost.org/",
|
|
824
870
|
poweredBy: "moostjs",
|
|
825
|
-
version: "0.
|
|
871
|
+
version: "0.7.0"
|
|
826
872
|
});
|
|
827
873
|
if (httpApp && httpApp instanceof _wooksjs_event_http.WooksHttp) this.httpApp = httpApp;
|
|
828
874
|
else if (httpApp) this.httpApp = (0, _wooksjs_event_http.createHttpApp)({
|
|
@@ -890,6 +936,12 @@ exports.CompressedBodySizeLimit = CompressedBodySizeLimit;
|
|
|
890
936
|
exports.Cookie = Cookie;
|
|
891
937
|
exports.CookieAttrsRef = CookieAttrsRef;
|
|
892
938
|
exports.CookieRef = CookieRef;
|
|
939
|
+
Object.defineProperty(exports, 'DEFAULT_HTTP_STATUS', {
|
|
940
|
+
enumerable: true,
|
|
941
|
+
get: function () {
|
|
942
|
+
return _wooksjs_event_http.DEFAULT_HTTP_STATUS;
|
|
943
|
+
}
|
|
944
|
+
});
|
|
893
945
|
exports.Delete = Delete;
|
|
894
946
|
exports.Get = Get;
|
|
895
947
|
exports.Header = Header;
|
|
@@ -922,6 +974,12 @@ exports.Url = Url;
|
|
|
922
974
|
exports.defineAuthGuard = defineAuthGuard;
|
|
923
975
|
exports.enableLocalFetch = enableLocalFetch;
|
|
924
976
|
exports.extractTransports = extractTransports;
|
|
977
|
+
Object.defineProperty(exports, 'getDefaultHttpStatus', {
|
|
978
|
+
enumerable: true,
|
|
979
|
+
get: function () {
|
|
980
|
+
return _wooksjs_event_http.getDefaultHttpStatus;
|
|
981
|
+
}
|
|
982
|
+
});
|
|
925
983
|
exports.globalBodyReadTimeoutMs = globalBodyReadTimeoutMs;
|
|
926
984
|
exports.globalBodySizeLimit = globalBodySizeLimit;
|
|
927
985
|
exports.globalCompressedBodySizeLimit = globalCompressedBodySizeLimit;
|
|
@@ -943,6 +1001,12 @@ Object.defineProperty(exports, 'prerenderJson', {
|
|
|
943
1001
|
return _wooksjs_event_http.prerenderJson;
|
|
944
1002
|
}
|
|
945
1003
|
});
|
|
1004
|
+
Object.defineProperty(exports, 'useAcceptLanguage', {
|
|
1005
|
+
enumerable: true,
|
|
1006
|
+
get: function () {
|
|
1007
|
+
return _wooksjs_event_http.useAcceptLanguage;
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
946
1010
|
Object.defineProperty(exports, 'useHttpContext', {
|
|
947
1011
|
enumerable: true,
|
|
948
1012
|
get: function () {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as moost from 'moost';
|
|
2
2
|
import { TInterceptorPriority, TOvertakeFn, TInterceptorDef, TClassConstructor, TMoostAdapter, MOOST_ADAPTER_BRAND, TIsolatedSlot, EventContext, Moost, TConsoleBase, TMoostAdapterOptions } from 'moost';
|
|
3
3
|
import * as _wooksjs_event_http from '@wooksjs/event-http';
|
|
4
|
-
import { TCookieAttributes as TCookieAttributes$1, TCookieAttributesInput, THttpCompressionOptions, WooksHttp, TWooksHttpOptions } from '@wooksjs/event-http';
|
|
5
|
-
export { HttpError, TCacheControl, TCookieAttributesInput, THttpCompressionEncoding, THttpCompressionOptions, TPrerenderJsonOptions, TSetCookieData, httpKind, isCompressibleType, prerenderJson, useHttpContext } from '@wooksjs/event-http';
|
|
4
|
+
import { TCookieAttributes as TCookieAttributes$1, TCookieAttributesInput, THttpCompressionOptions, WooksHttp, TWooksHttpOptions, TFetchPeer } from '@wooksjs/event-http';
|
|
5
|
+
export { DEFAULT_HTTP_STATUS, HttpError, TCacheControl, TCookieAttributesInput, TFetchPeer, TForwardedInfo, THttpCompressionEncoding, THttpCompressionOptions, THttpErrorBody, TPrerenderJsonOptions, TProxyHeaders, TSetCookieData, TTransformErrorBody, TTrustProxy, TTrustProxyFn, getDefaultHttpStatus, httpKind, isCompressibleType, prerenderJson, useAcceptLanguage, useHttpContext } from '@wooksjs/event-http';
|
|
6
6
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
7
7
|
import { Buffer } from 'buffer';
|
|
8
8
|
import { ListenOptions } from 'net';
|
|
@@ -155,7 +155,10 @@ declare function Header(name: string): ParameterDecorator & PropertyDecorator;
|
|
|
155
155
|
*/
|
|
156
156
|
declare function Cookie(name: string): ParameterDecorator & PropertyDecorator;
|
|
157
157
|
/**
|
|
158
|
-
* Get Query Item value or the whole parsed Query as an object
|
|
158
|
+
* Get Query Item value or the whole parsed Query as an object.
|
|
159
|
+
*
|
|
160
|
+
* Without `name`, resolves the parsed query — `{}` when the request has no query string.
|
|
161
|
+
* With `name`, resolves that item's value, or `undefined` when it is absent.
|
|
159
162
|
* @decorator
|
|
160
163
|
* @param name - query item name (optional)
|
|
161
164
|
* @paramType string | object
|
|
@@ -195,7 +198,18 @@ declare function Res(opts?: {
|
|
|
195
198
|
*/
|
|
196
199
|
declare function ReqId(): ParameterDecorator & PropertyDecorator;
|
|
197
200
|
/**
|
|
198
|
-
* Get
|
|
201
|
+
* Get the client IP address.
|
|
202
|
+
*
|
|
203
|
+
* Without arguments it follows the app's `trustProxy` setting (`new MoostHttp({ trustProxy })`):
|
|
204
|
+
* the socket peer when no proxy is trusted (the default), else the right-most untrusted
|
|
205
|
+
* `X-Forwarded-For` / `Forwarded` hop. IPv4-mapped addresses are returned as plain IPv4;
|
|
206
|
+
* `''` when the client is unknown (an in-process `fetch()` without a peer, a malformed
|
|
207
|
+
* forwarding entry from a trusted proxy).
|
|
208
|
+
*
|
|
209
|
+
* @param opts - **Deprecated:** `{ trustProxy: true }` trusts exactly ONE proxy hop (the
|
|
210
|
+
* right-most `X-Forwarded-For` entry, no longer the forgeable left-most one);
|
|
211
|
+
* `{ trustProxy: false }` returns the socket peer. Configure `trustProxy` on `MoostHttp`
|
|
212
|
+
* instead and use `@Ip()`.
|
|
199
213
|
* @decorator
|
|
200
214
|
* @paramType string
|
|
201
215
|
*/
|
|
@@ -203,9 +217,10 @@ declare function Ip(opts?: {
|
|
|
203
217
|
trustProxy: boolean;
|
|
204
218
|
}): ParameterDecorator & PropertyDecorator;
|
|
205
219
|
/**
|
|
206
|
-
* Get
|
|
220
|
+
* Get the raw address list: the socket peer and every `X-Forwarded-For` entry, unvalidated
|
|
221
|
+
* (client-forgeable — use `@Ip()` for the client address).
|
|
207
222
|
* @decorator
|
|
208
|
-
* @paramType string[]
|
|
223
|
+
* @paramType { remoteIp: string, forwarded: string[] }
|
|
209
224
|
*/
|
|
210
225
|
declare function IpList(): ParameterDecorator & PropertyDecorator;
|
|
211
226
|
/**
|
|
@@ -482,9 +497,18 @@ declare class MoostHttp implements TMoostAdapter<THttpHandlerMeta> {
|
|
|
482
497
|
* argument resolution, pipes, validation, and handler execution.
|
|
483
498
|
*
|
|
484
499
|
* When called from within an existing HTTP context (e.g. during SSR),
|
|
485
|
-
* identity headers (authorization, cookie) are automatically forwarded
|
|
500
|
+
* identity headers (authorization, cookie) are automatically forwarded, and the
|
|
501
|
+
* inner request inherits the caller's client (`@Ip()`, protocol, host) and locale.
|
|
502
|
+
*
|
|
503
|
+
* Serving a fetch runtime (Bun, Deno, edge) with no calling request, pass the connection's
|
|
504
|
+
* `peer` — without it the client address is unknown (`@Ip()` is `''`) and an address-based
|
|
505
|
+
* `trustProxy` trusts nothing.
|
|
506
|
+
*
|
|
507
|
+
* @param request - A Web Standard Request.
|
|
508
|
+
* @param peer - `remoteAddress` of the connection (the client, or the proxy in front) and
|
|
509
|
+
* `encrypted` (TLS; default: the URL scheme).
|
|
486
510
|
*/
|
|
487
|
-
fetch(request: Request): Promise<Response | null>;
|
|
511
|
+
fetch(request: Request, peer?: TFetchPeer): Promise<Response | null>;
|
|
488
512
|
/**
|
|
489
513
|
* Convenience wrapper for programmatic route invocation.
|
|
490
514
|
* Accepts a URL string (relative paths auto-prefixed with `http://localhost`),
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { current, eventTypeKey, key } from "@wooksjs/event-core";
|
|
2
|
-
import { HttpError, HttpError as HttpError$1, WooksHttp, WooksHttpResponse, createHttpApp, httpKind, httpKind as httpKind$1, isCompressibleType, prerenderJson, useAuthorization, useCookies, useHeaders, useHttpContext, useRequest, useResponse, useUrlParams } from "@wooksjs/event-http";
|
|
2
|
+
import { DEFAULT_HTTP_STATUS, HttpError, HttpError as HttpError$1, WooksHttp, WooksHttpResponse, createHttpApp, getDefaultHttpStatus, httpKind, httpKind as httpKind$1, isCompressibleType, prerenderJson, useAcceptLanguage, useAuthorization, useCookies, useHeaders, useHttpContext, useRequest, useResponse, useUrlParams } from "@wooksjs/event-http";
|
|
3
3
|
import { Before, Intercept, Interceptor, MOOST_ADAPTER_BRAND, Overtake, Resolve, TInterceptorPriority, current as current$1, defineBeforeInterceptor, defineMoostEventHandler, forkEventContext, getMoostMate, globalKey, run } from "moost";
|
|
4
4
|
import { seedBody, useBody } from "@wooksjs/http-body";
|
|
5
5
|
import { createProvideRegistry } from "@prostojs/infact";
|
|
6
6
|
import { Server } from "http";
|
|
7
7
|
import { Server as Server$1 } from "https";
|
|
8
|
+
import { Socket } from "net";
|
|
8
9
|
|
|
9
10
|
//#region packages/event-http/src/auth-guard.ts
|
|
10
11
|
function _define_property$1(obj, key, value) {
|
|
@@ -293,7 +294,10 @@ function createRef(getter, setter) {
|
|
|
293
294
|
return Resolve(() => useCookies().getCookie(name), `cookie: ${name}`);
|
|
294
295
|
}
|
|
295
296
|
/**
|
|
296
|
-
* Get Query Item value or the whole parsed Query as an object
|
|
297
|
+
* Get Query Item value or the whole parsed Query as an object.
|
|
298
|
+
*
|
|
299
|
+
* Without `name`, resolves the parsed query — `{}` when the request has no query string.
|
|
300
|
+
* With `name`, resolves that item's value, or `undefined` when it is absent.
|
|
297
301
|
* @decorator
|
|
298
302
|
* @param name - query item name (optional)
|
|
299
303
|
* @paramType string | object
|
|
@@ -306,8 +310,7 @@ function createRef(getter, setter) {
|
|
|
306
310
|
const value = params().get(name);
|
|
307
311
|
return value === null ? void 0 : value;
|
|
308
312
|
}
|
|
309
|
-
|
|
310
|
-
return Object.keys(json).length > 0 ? json : void 0;
|
|
313
|
+
return toJson();
|
|
311
314
|
}, _name));
|
|
312
315
|
}
|
|
313
316
|
/**
|
|
@@ -347,16 +350,28 @@ function createRef(getter, setter) {
|
|
|
347
350
|
return Resolve(() => useRequest().reqId(), "reqId");
|
|
348
351
|
}
|
|
349
352
|
/**
|
|
350
|
-
* Get
|
|
353
|
+
* Get the client IP address.
|
|
354
|
+
*
|
|
355
|
+
* Without arguments it follows the app's `trustProxy` setting (`new MoostHttp({ trustProxy })`):
|
|
356
|
+
* the socket peer when no proxy is trusted (the default), else the right-most untrusted
|
|
357
|
+
* `X-Forwarded-For` / `Forwarded` hop. IPv4-mapped addresses are returned as plain IPv4;
|
|
358
|
+
* `''` when the client is unknown (an in-process `fetch()` without a peer, a malformed
|
|
359
|
+
* forwarding entry from a trusted proxy).
|
|
360
|
+
*
|
|
361
|
+
* @param opts - **Deprecated:** `{ trustProxy: true }` trusts exactly ONE proxy hop (the
|
|
362
|
+
* right-most `X-Forwarded-For` entry, no longer the forgeable left-most one);
|
|
363
|
+
* `{ trustProxy: false }` returns the socket peer. Configure `trustProxy` on `MoostHttp`
|
|
364
|
+
* instead and use `@Ip()`.
|
|
351
365
|
* @decorator
|
|
352
366
|
* @paramType string
|
|
353
367
|
*/ function Ip(opts) {
|
|
354
368
|
return Resolve(() => useRequest().getIp(opts), "ip");
|
|
355
369
|
}
|
|
356
370
|
/**
|
|
357
|
-
* Get
|
|
371
|
+
* Get the raw address list: the socket peer and every `X-Forwarded-For` entry, unvalidated
|
|
372
|
+
* (client-forgeable — use `@Ip()` for the client address).
|
|
358
373
|
* @decorator
|
|
359
|
-
* @paramType string[]
|
|
374
|
+
* @paramType { remoteIp: string, forwarded: string[] }
|
|
360
375
|
*/ function IpList() {
|
|
361
376
|
return Resolve(() => useRequest().getIpList(), "ipList");
|
|
362
377
|
}
|
|
@@ -602,15 +617,37 @@ function _define_property(obj, key, value) {
|
|
|
602
617
|
return obj;
|
|
603
618
|
}
|
|
604
619
|
/** Marks the child context of {@link MoostHttp.invoke}. */ const invocationKey = globalKey("moost-http.invocation");
|
|
620
|
+
/**
|
|
621
|
+
* Releases of queued (pipelined) responses per connection: one socket 'close' listener per
|
|
622
|
+
* connection, however many requests are queued on it.
|
|
623
|
+
*/ const queuedReleases = /* @__PURE__ */ new WeakMap();
|
|
624
|
+
function releaseQueued() {
|
|
625
|
+
const releases = queuedReleases.get(this);
|
|
626
|
+
queuedReleases.delete(this);
|
|
627
|
+
releases?.forEach((release) => release());
|
|
628
|
+
}
|
|
605
629
|
const holdScopeUntilResponseCloses = { init: ({ unscope }) => {
|
|
606
630
|
const ctx = current$1();
|
|
607
|
-
|
|
631
|
+
const res = ctx.hasOwn(invocationKey) ? void 0 : useResponse(ctx).getRawRes(true);
|
|
632
|
+
const connection = res && !res.closed ? res.socket ?? res.req?.socket : void 0;
|
|
633
|
+
if (!res || !(connection instanceof Socket)) {
|
|
608
634
|
unscope();
|
|
609
635
|
return;
|
|
610
636
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
637
|
+
if (res.socket) {
|
|
638
|
+
res.on("close", unscope);
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
let releases = queuedReleases.get(connection);
|
|
642
|
+
if (!releases) {
|
|
643
|
+
queuedReleases.set(connection, releases = /* @__PURE__ */ new Set());
|
|
644
|
+
connection.once("close", releaseQueued);
|
|
645
|
+
}
|
|
646
|
+
releases.add(unscope);
|
|
647
|
+
res.on("close", () => {
|
|
648
|
+
releases.delete(unscope);
|
|
649
|
+
unscope();
|
|
650
|
+
});
|
|
614
651
|
} };
|
|
615
652
|
const LOGGER_TITLE = "moost-http";
|
|
616
653
|
/**
|
|
@@ -656,9 +693,18 @@ const LOGGER_TITLE = "moost-http";
|
|
|
656
693
|
* argument resolution, pipes, validation, and handler execution.
|
|
657
694
|
*
|
|
658
695
|
* When called from within an existing HTTP context (e.g. during SSR),
|
|
659
|
-
* identity headers (authorization, cookie) are automatically forwarded
|
|
660
|
-
|
|
661
|
-
|
|
696
|
+
* identity headers (authorization, cookie) are automatically forwarded, and the
|
|
697
|
+
* inner request inherits the caller's client (`@Ip()`, protocol, host) and locale.
|
|
698
|
+
*
|
|
699
|
+
* Serving a fetch runtime (Bun, Deno, edge) with no calling request, pass the connection's
|
|
700
|
+
* `peer` — without it the client address is unknown (`@Ip()` is `''`) and an address-based
|
|
701
|
+
* `trustProxy` trusts nothing.
|
|
702
|
+
*
|
|
703
|
+
* @param request - A Web Standard Request.
|
|
704
|
+
* @param peer - `remoteAddress` of the connection (the client, or the proxy in front) and
|
|
705
|
+
* `encrypted` (TLS; default: the URL scheme).
|
|
706
|
+
*/ fetch(request, peer) {
|
|
707
|
+
return this.httpApp.fetch(request, peer);
|
|
662
708
|
}
|
|
663
709
|
/**
|
|
664
710
|
* Convenience wrapper for programmatic route invocation.
|
|
@@ -821,7 +867,7 @@ const LOGGER_TITLE = "moost-http";
|
|
|
821
867
|
image: "https://moost.org/moost-full-logo.svg",
|
|
822
868
|
link: "https://moost.org/",
|
|
823
869
|
poweredBy: "moostjs",
|
|
824
|
-
version: "0.
|
|
870
|
+
version: "0.7.0"
|
|
825
871
|
});
|
|
826
872
|
if (httpApp && httpApp instanceof WooksHttp) this.httpApp = httpApp;
|
|
827
873
|
else if (httpApp) this.httpApp = createHttpApp({
|
|
@@ -872,4 +918,4 @@ function isLocalOrigin(url) {
|
|
|
872
918
|
}
|
|
873
919
|
|
|
874
920
|
//#endregion
|
|
875
|
-
export { All, AuthGuard, Authenticate, Authorization, Body, BodyReadTimeoutMs, BodySizeLimit, Compress, 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, enableLocalFetch, extractTransports, globalBodyReadTimeoutMs, globalBodySizeLimit, globalCompressedBodySizeLimit, httpKind, isCompressibleType, prerenderJson, useHttpContext };
|
|
921
|
+
export { All, AuthGuard, Authenticate, Authorization, Body, BodyReadTimeoutMs, BodySizeLimit, Compress, CompressedBodySizeLimit, Cookie, CookieAttrsRef, CookieRef, DEFAULT_HTTP_STATUS, 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, enableLocalFetch, extractTransports, getDefaultHttpStatus, globalBodyReadTimeoutMs, globalBodySizeLimit, globalCompressedBodySizeLimit, httpKind, isCompressibleType, prerenderJson, useAcceptLanguage, useHttpContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "@moostjs/event-http",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"composables",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@wooksjs/event-http": "^0.
|
|
42
|
-
"@wooksjs/http-body": "^0.
|
|
41
|
+
"@wooksjs/event-http": "^0.8.0",
|
|
42
|
+
"@wooksjs/http-body": "^0.8.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"vitest": "3.2.7",
|
|
46
|
-
"@moostjs/event-wf": "^0.
|
|
46
|
+
"@moostjs/event-wf": "^0.7.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@prostojs/infact": "^0.6.1",
|
|
50
|
-
"@wooksjs/event-core": "^0.
|
|
51
|
-
"moost": "^0.
|
|
50
|
+
"@wooksjs/event-core": "^0.8.0",
|
|
51
|
+
"moost": "^0.7.0"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"pub": "pnpm publish --access public",
|