@h3ravel/http 11.5.3 → 11.6.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 +39 -6
- package/dist/index.d.cts +35 -8
- package/dist/index.d.ts +35 -8
- package/dist/index.js +39 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -19032,6 +19032,44 @@ var FormRequest = class {
|
|
|
19032
19032
|
}
|
|
19033
19033
|
};
|
|
19034
19034
|
|
|
19035
|
+
//#endregion
|
|
19036
|
+
//#region src/HttpContext.ts
|
|
19037
|
+
/**
|
|
19038
|
+
* Represents the HTTP context for a single request lifecycle.
|
|
19039
|
+
* Encapsulates the application instance, request, and response objects.
|
|
19040
|
+
*/
|
|
19041
|
+
var HttpContext = class HttpContext {
|
|
19042
|
+
static contexts = /* @__PURE__ */ new WeakMap();
|
|
19043
|
+
constructor(app, request, response) {
|
|
19044
|
+
this.app = app;
|
|
19045
|
+
this.request = request;
|
|
19046
|
+
this.response = response;
|
|
19047
|
+
}
|
|
19048
|
+
/**
|
|
19049
|
+
* Factory method to create a new HttpContext instance from a context object.
|
|
19050
|
+
* @param ctx - Object containing app, request, and response
|
|
19051
|
+
* @returns A new HttpContext instance
|
|
19052
|
+
*/
|
|
19053
|
+
static init(ctx, event) {
|
|
19054
|
+
if (event && HttpContext.contexts.has(event)) return HttpContext.contexts.get(event);
|
|
19055
|
+
const instance = new HttpContext(ctx.app, ctx.request, ctx.response);
|
|
19056
|
+
if (event) HttpContext.contexts.set(event, instance);
|
|
19057
|
+
return instance;
|
|
19058
|
+
}
|
|
19059
|
+
/**
|
|
19060
|
+
* Retrieve an existing HttpContext instance for an event, if any.
|
|
19061
|
+
*/
|
|
19062
|
+
static get(event) {
|
|
19063
|
+
return HttpContext.contexts.get(event);
|
|
19064
|
+
}
|
|
19065
|
+
/**
|
|
19066
|
+
* Delete the cached context for a given event (optional cleanup).
|
|
19067
|
+
*/
|
|
19068
|
+
static forget(event) {
|
|
19069
|
+
HttpContext.contexts.delete(event);
|
|
19070
|
+
}
|
|
19071
|
+
};
|
|
19072
|
+
|
|
19035
19073
|
//#endregion
|
|
19036
19074
|
//#region src/Middleware.ts
|
|
19037
19075
|
var Middleware = class {};
|
|
@@ -19895,12 +19933,7 @@ exports.FileBag = FileBag;
|
|
|
19895
19933
|
exports.FireCommand = FireCommand;
|
|
19896
19934
|
exports.FormRequest = FormRequest;
|
|
19897
19935
|
exports.HeaderBag = HeaderBag;
|
|
19898
|
-
|
|
19899
|
-
enumerable: true,
|
|
19900
|
-
get: function () {
|
|
19901
|
-
return __h3ravel_shared.HttpContext;
|
|
19902
|
-
}
|
|
19903
|
-
});
|
|
19936
|
+
exports.HttpContext = HttpContext;
|
|
19904
19937
|
exports.HttpServiceProvider = HttpServiceProvider;
|
|
19905
19938
|
exports.InputBag = InputBag;
|
|
19906
19939
|
exports.JsonResource = JsonResource;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
2
|
import { EventHandlerRequest, H3Event, HTTPResponse } from "h3";
|
|
3
|
-
import { DotNestedKeys, DotNestedValue, HttpContext
|
|
3
|
+
import { DotNestedKeys, DotNestedValue, HttpContext as HttpContext$1, IApplication, IMiddleware, IParamBag, IRequest, IResponse, RequestMethod, RequestObject } from "@h3ravel/shared";
|
|
4
4
|
import { Command } from "@h3ravel/musket";
|
|
5
5
|
import { Application } from "@h3ravel/core";
|
|
6
6
|
import { Url } from "@h3ravel/url";
|
|
7
7
|
|
|
8
|
-
//#region src/Contracts/HttpContract.d.ts
|
|
9
|
-
type RequestMethod = 'HEAD' | 'GET' | 'PUT' | 'DELETE' | 'TRACE' | 'OPTIONS' | 'PURGE' | 'POST' | 'CONNECT' | 'PATCH';
|
|
10
|
-
type RequestObject = Record<string, any>;
|
|
11
|
-
//#endregion
|
|
12
8
|
//#region src/Bags/ParamBag.d.ts
|
|
13
9
|
/**
|
|
14
10
|
* ParamBag is a container for key/value pairs
|
|
15
11
|
* for Node/H3 environments.
|
|
16
12
|
*/
|
|
17
|
-
declare class ParamBag implements
|
|
13
|
+
declare class ParamBag implements IParamBag {
|
|
18
14
|
protected parameters: RequestObject;
|
|
19
15
|
/**
|
|
20
16
|
* The current H3 H3Event instance
|
|
@@ -515,6 +511,37 @@ declare class FormRequest {
|
|
|
515
511
|
all(): Record<string, any>;
|
|
516
512
|
}
|
|
517
513
|
//#endregion
|
|
514
|
+
//#region src/HttpContext.d.ts
|
|
515
|
+
/**
|
|
516
|
+
* Represents the HTTP context for a single request lifecycle.
|
|
517
|
+
* Encapsulates the application instance, request, and response objects.
|
|
518
|
+
*/
|
|
519
|
+
declare class HttpContext implements HttpContext$1 {
|
|
520
|
+
app: IApplication;
|
|
521
|
+
request: IRequest;
|
|
522
|
+
response: IResponse;
|
|
523
|
+
private static contexts;
|
|
524
|
+
constructor(app: IApplication, request: IRequest, response: IResponse);
|
|
525
|
+
/**
|
|
526
|
+
* Factory method to create a new HttpContext instance from a context object.
|
|
527
|
+
* @param ctx - Object containing app, request, and response
|
|
528
|
+
* @returns A new HttpContext instance
|
|
529
|
+
*/
|
|
530
|
+
static init(ctx: {
|
|
531
|
+
app: IApplication;
|
|
532
|
+
request: IRequest;
|
|
533
|
+
response: IResponse;
|
|
534
|
+
}, event?: unknown): HttpContext;
|
|
535
|
+
/**
|
|
536
|
+
* Retrieve an existing HttpContext instance for an event, if any.
|
|
537
|
+
*/
|
|
538
|
+
static get(event: unknown): HttpContext | undefined;
|
|
539
|
+
/**
|
|
540
|
+
* Delete the cached context for a given event (optional cleanup).
|
|
541
|
+
*/
|
|
542
|
+
static forget(event: unknown): void;
|
|
543
|
+
}
|
|
544
|
+
//#endregion
|
|
518
545
|
//#region src/Middleware.d.ts
|
|
519
546
|
declare abstract class Middleware implements IMiddleware {
|
|
520
547
|
abstract handle(context: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
|
|
@@ -524,7 +551,7 @@ declare abstract class Middleware implements IMiddleware {
|
|
|
524
551
|
declare class LogRequests extends Middleware {
|
|
525
552
|
handle({
|
|
526
553
|
request
|
|
527
|
-
}: HttpContext
|
|
554
|
+
}: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
|
|
528
555
|
}
|
|
529
556
|
//#endregion
|
|
530
557
|
//#region src/Providers/HttpServiceProvider.d.ts
|
|
@@ -1054,4 +1081,4 @@ declare class Response implements IResponse {
|
|
|
1054
1081
|
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
1055
1082
|
}
|
|
1056
1083
|
//#endregion
|
|
1057
|
-
export { ApiResource, BadRequestException, FileBag, FireCommand, FormRequest, HeaderBag, HttpContext, HttpServiceProvider, InputBag, JsonResource, LogRequests, Middleware, ParamBag, Request,
|
|
1084
|
+
export { ApiResource, BadRequestException, FileBag, FireCommand, FormRequest, HeaderBag, HttpContext, HttpServiceProvider, InputBag, JsonResource, LogRequests, Middleware, ParamBag, Request, Resource, Response, ServerBag, SuspiciousOperationException, UnexpectedValueException, UploadedFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
2
|
import { Command } from "@h3ravel/musket";
|
|
3
|
-
import { DotNestedKeys, DotNestedValue, HttpContext
|
|
3
|
+
import { DotNestedKeys, DotNestedValue, HttpContext as HttpContext$1, IApplication, IMiddleware, IParamBag, IRequest, IResponse, RequestMethod, RequestObject } from "@h3ravel/shared";
|
|
4
4
|
import { EventHandlerRequest, H3Event, HTTPResponse } from "h3";
|
|
5
5
|
import { Application } from "@h3ravel/core";
|
|
6
6
|
import { Url } from "@h3ravel/url";
|
|
7
7
|
|
|
8
|
-
//#region src/Contracts/HttpContract.d.ts
|
|
9
|
-
type RequestMethod = 'HEAD' | 'GET' | 'PUT' | 'DELETE' | 'TRACE' | 'OPTIONS' | 'PURGE' | 'POST' | 'CONNECT' | 'PATCH';
|
|
10
|
-
type RequestObject = Record<string, any>;
|
|
11
|
-
//#endregion
|
|
12
8
|
//#region src/Bags/ParamBag.d.ts
|
|
13
9
|
/**
|
|
14
10
|
* ParamBag is a container for key/value pairs
|
|
15
11
|
* for Node/H3 environments.
|
|
16
12
|
*/
|
|
17
|
-
declare class ParamBag implements
|
|
13
|
+
declare class ParamBag implements IParamBag {
|
|
18
14
|
protected parameters: RequestObject;
|
|
19
15
|
/**
|
|
20
16
|
* The current H3 H3Event instance
|
|
@@ -515,6 +511,37 @@ declare class FormRequest {
|
|
|
515
511
|
all(): Record<string, any>;
|
|
516
512
|
}
|
|
517
513
|
//#endregion
|
|
514
|
+
//#region src/HttpContext.d.ts
|
|
515
|
+
/**
|
|
516
|
+
* Represents the HTTP context for a single request lifecycle.
|
|
517
|
+
* Encapsulates the application instance, request, and response objects.
|
|
518
|
+
*/
|
|
519
|
+
declare class HttpContext implements HttpContext$1 {
|
|
520
|
+
app: IApplication;
|
|
521
|
+
request: IRequest;
|
|
522
|
+
response: IResponse;
|
|
523
|
+
private static contexts;
|
|
524
|
+
constructor(app: IApplication, request: IRequest, response: IResponse);
|
|
525
|
+
/**
|
|
526
|
+
* Factory method to create a new HttpContext instance from a context object.
|
|
527
|
+
* @param ctx - Object containing app, request, and response
|
|
528
|
+
* @returns A new HttpContext instance
|
|
529
|
+
*/
|
|
530
|
+
static init(ctx: {
|
|
531
|
+
app: IApplication;
|
|
532
|
+
request: IRequest;
|
|
533
|
+
response: IResponse;
|
|
534
|
+
}, event?: unknown): HttpContext;
|
|
535
|
+
/**
|
|
536
|
+
* Retrieve an existing HttpContext instance for an event, if any.
|
|
537
|
+
*/
|
|
538
|
+
static get(event: unknown): HttpContext | undefined;
|
|
539
|
+
/**
|
|
540
|
+
* Delete the cached context for a given event (optional cleanup).
|
|
541
|
+
*/
|
|
542
|
+
static forget(event: unknown): void;
|
|
543
|
+
}
|
|
544
|
+
//#endregion
|
|
518
545
|
//#region src/Middleware.d.ts
|
|
519
546
|
declare abstract class Middleware implements IMiddleware {
|
|
520
547
|
abstract handle(context: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
|
|
@@ -524,7 +551,7 @@ declare abstract class Middleware implements IMiddleware {
|
|
|
524
551
|
declare class LogRequests extends Middleware {
|
|
525
552
|
handle({
|
|
526
553
|
request
|
|
527
|
-
}: HttpContext
|
|
554
|
+
}: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
|
|
528
555
|
}
|
|
529
556
|
//#endregion
|
|
530
557
|
//#region src/Providers/HttpServiceProvider.d.ts
|
|
@@ -1054,4 +1081,4 @@ declare class Response implements IResponse {
|
|
|
1054
1081
|
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
1055
1082
|
}
|
|
1056
1083
|
//#endregion
|
|
1057
|
-
export { ApiResource, BadRequestException, FileBag, FireCommand, FormRequest, HeaderBag, HttpContext, HttpServiceProvider, InputBag, JsonResource, LogRequests, Middleware, ParamBag, Request,
|
|
1084
|
+
export { ApiResource, BadRequestException, FileBag, FireCommand, FormRequest, HeaderBag, HttpContext, HttpServiceProvider, InputBag, JsonResource, LogRequests, Middleware, ParamBag, Request, Resource, Response, ServerBag, SuspiciousOperationException, UnexpectedValueException, UploadedFile };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { i as __toESM, r as __require, t as __commonJS } from "./chunk-BLWcukCW.
|
|
|
2
2
|
import { writeFile } from "fs/promises";
|
|
3
3
|
import { Arr, Obj, Str, data_get, data_set, safeDot } from "@h3ravel/support";
|
|
4
4
|
import { Command } from "@h3ravel/musket";
|
|
5
|
-
import {
|
|
5
|
+
import { Logger } from "@h3ravel/shared";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
|
|
8
8
|
import { StringDecoder } from "node:string_decoder";
|
|
@@ -19012,6 +19012,44 @@ var FormRequest = class {
|
|
|
19012
19012
|
}
|
|
19013
19013
|
};
|
|
19014
19014
|
|
|
19015
|
+
//#endregion
|
|
19016
|
+
//#region src/HttpContext.ts
|
|
19017
|
+
/**
|
|
19018
|
+
* Represents the HTTP context for a single request lifecycle.
|
|
19019
|
+
* Encapsulates the application instance, request, and response objects.
|
|
19020
|
+
*/
|
|
19021
|
+
var HttpContext = class HttpContext {
|
|
19022
|
+
static contexts = /* @__PURE__ */ new WeakMap();
|
|
19023
|
+
constructor(app, request, response) {
|
|
19024
|
+
this.app = app;
|
|
19025
|
+
this.request = request;
|
|
19026
|
+
this.response = response;
|
|
19027
|
+
}
|
|
19028
|
+
/**
|
|
19029
|
+
* Factory method to create a new HttpContext instance from a context object.
|
|
19030
|
+
* @param ctx - Object containing app, request, and response
|
|
19031
|
+
* @returns A new HttpContext instance
|
|
19032
|
+
*/
|
|
19033
|
+
static init(ctx, event) {
|
|
19034
|
+
if (event && HttpContext.contexts.has(event)) return HttpContext.contexts.get(event);
|
|
19035
|
+
const instance = new HttpContext(ctx.app, ctx.request, ctx.response);
|
|
19036
|
+
if (event) HttpContext.contexts.set(event, instance);
|
|
19037
|
+
return instance;
|
|
19038
|
+
}
|
|
19039
|
+
/**
|
|
19040
|
+
* Retrieve an existing HttpContext instance for an event, if any.
|
|
19041
|
+
*/
|
|
19042
|
+
static get(event) {
|
|
19043
|
+
return HttpContext.contexts.get(event);
|
|
19044
|
+
}
|
|
19045
|
+
/**
|
|
19046
|
+
* Delete the cached context for a given event (optional cleanup).
|
|
19047
|
+
*/
|
|
19048
|
+
static forget(event) {
|
|
19049
|
+
HttpContext.contexts.delete(event);
|
|
19050
|
+
}
|
|
19051
|
+
};
|
|
19052
|
+
|
|
19015
19053
|
//#endregion
|
|
19016
19054
|
//#region src/Middleware.ts
|
|
19017
19055
|
var Middleware = class {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/http",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.6.0",
|
|
4
4
|
"description": "HTTP kernel, middleware pipeline, request/response classes for H3ravel.",
|
|
5
5
|
"h3ravel": {
|
|
6
6
|
"providers": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"h3": "2.0.1-rc.5",
|
|
46
46
|
"srvx": "^0.8.2",
|
|
47
47
|
"@h3ravel/support": "^0.14.4",
|
|
48
|
-
"@h3ravel/shared": "^0.
|
|
48
|
+
"@h3ravel/shared": "^0.26.0",
|
|
49
49
|
"@h3ravel/url": "^1.0.8"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|