@h3ravel/http 11.0.0 → 11.2.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/README.md +13 -1
- package/dist/chunk-BncF-t-1.cjs +48 -0
- package/dist/chunk-qJlxXUkR.js +33 -0
- package/dist/find-up-simple-CPevfdC2.cjs +37 -0
- package/dist/find-up-simple-CPevfdC2.cjs.map +1 -0
- package/dist/find-up-simple-DLa63O5_.js +32 -0
- package/dist/find-up-simple-DLa63O5_.js.map +1 -0
- package/dist/index.cjs +18672 -370
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -184
- package/dist/index.d.ts +210 -184
- package/dist/index.js +18649 -347
- package/dist/index.js.map +1 -1
- package/dist/stubs/controller-resource.stub +34 -0
- package/dist/stubs/controller.stub +3 -0
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { DotNestedKeys, DotNestedValue } from '@h3ravel/support';
|
|
6
|
-
import { TypedHeaders, ResponseHeaderMap } from 'fetchdts';
|
|
1
|
+
import { Application, ConsoleCommand, ServiceProvider } from "@h3ravel/core";
|
|
2
|
+
import { DotNestedKeys, DotNestedValue, HttpContext, HttpContext as HttpContext$1, IMiddleware, IRequest, IResponse } from "@h3ravel/shared";
|
|
3
|
+
import { EventHandlerRequest, H3Event } from "h3";
|
|
4
|
+
import { ResponseHeaderMap, TypedHeaders } from "fetchdts";
|
|
7
5
|
|
|
6
|
+
//#region src/Commands/FireCommand.d.ts
|
|
7
|
+
declare class FireCommand extends ConsoleCommand {
|
|
8
|
+
/**
|
|
9
|
+
* The name and signature of the console command.
|
|
10
|
+
*
|
|
11
|
+
* @var string
|
|
12
|
+
*/
|
|
13
|
+
protected signature: string;
|
|
14
|
+
/**
|
|
15
|
+
* The console command description.
|
|
16
|
+
*
|
|
17
|
+
* @var string
|
|
18
|
+
*/
|
|
19
|
+
protected description: string;
|
|
20
|
+
handle(): Promise<void>;
|
|
21
|
+
protected fire(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/Middleware.d.ts
|
|
8
25
|
declare abstract class Middleware implements IMiddleware {
|
|
9
|
-
|
|
26
|
+
abstract handle(context: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
|
|
10
27
|
}
|
|
11
|
-
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/Middleware/LogRequests.d.ts
|
|
12
30
|
declare class LogRequests extends Middleware {
|
|
13
|
-
|
|
31
|
+
handle({
|
|
32
|
+
request
|
|
33
|
+
}: HttpContext$1, next: () => Promise<unknown>): Promise<unknown>;
|
|
14
34
|
}
|
|
15
|
-
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/Providers/HttpServiceProvider.d.ts
|
|
16
37
|
/**
|
|
17
38
|
* Sets up HTTP kernel and request lifecycle.
|
|
18
39
|
*
|
|
@@ -23,193 +44,198 @@ declare class LogRequests extends Middleware {
|
|
|
23
44
|
* Auto-Registered
|
|
24
45
|
*/
|
|
25
46
|
declare class HttpServiceProvider extends ServiceProvider {
|
|
26
|
-
|
|
27
|
-
|
|
47
|
+
static priority: number;
|
|
48
|
+
register(): void;
|
|
28
49
|
}
|
|
29
|
-
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/Request.d.ts
|
|
30
52
|
declare class Request implements IRequest {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The current app instance
|
|
55
|
+
*/
|
|
56
|
+
app: Application;
|
|
57
|
+
/**
|
|
58
|
+
* Gets route parameters.
|
|
59
|
+
* @returns An object containing route parameters.
|
|
60
|
+
*/
|
|
61
|
+
readonly params: NonNullable<H3Event["context"]["params"]>;
|
|
62
|
+
/**
|
|
63
|
+
* Gets query parameters.
|
|
64
|
+
* @returns An object containing query parameters.
|
|
65
|
+
*/
|
|
66
|
+
readonly query: Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the request headers.
|
|
69
|
+
* @returns An object containing request headers.
|
|
70
|
+
*/
|
|
71
|
+
readonly headers: TypedHeaders<Record<keyof ResponseHeaderMap, string>>;
|
|
72
|
+
/**
|
|
73
|
+
* The current H3 H3Event instance
|
|
74
|
+
*/
|
|
75
|
+
private readonly event;
|
|
76
|
+
constructor(event: H3Event,
|
|
77
|
+
/**
|
|
78
|
+
* The current app instance
|
|
79
|
+
*/
|
|
80
|
+
app: Application);
|
|
81
|
+
/**
|
|
82
|
+
* Get all input data (query + body).
|
|
83
|
+
*/
|
|
84
|
+
all<T = Record<string, unknown>>(): Promise<T>;
|
|
85
|
+
/**
|
|
86
|
+
* Get a single input field from query or body.
|
|
87
|
+
*/
|
|
88
|
+
input<T = unknown>(key: string, defaultValue?: T): Promise<T>;
|
|
89
|
+
/**
|
|
90
|
+
* Get the base event
|
|
91
|
+
*/
|
|
92
|
+
getEvent(): H3Event;
|
|
93
|
+
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
72
94
|
}
|
|
73
|
-
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/Resources/JsonResource.d.ts
|
|
74
97
|
interface Resource {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
98
|
+
[key: string]: any;
|
|
99
|
+
pagination?: {
|
|
100
|
+
from?: number | undefined;
|
|
101
|
+
to?: number | undefined;
|
|
102
|
+
perPage?: number | undefined;
|
|
103
|
+
total?: number | undefined;
|
|
104
|
+
} | undefined;
|
|
82
105
|
}
|
|
83
106
|
type BodyResource = Resource & {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
107
|
+
data: Omit<Resource, 'pagination'>;
|
|
108
|
+
meta?: {
|
|
109
|
+
pagination?: Resource['pagination'];
|
|
110
|
+
} | undefined;
|
|
88
111
|
};
|
|
89
112
|
/**
|
|
90
113
|
* Class to render API resource
|
|
91
114
|
*/
|
|
92
115
|
declare class JsonResource<R extends Resource = any> {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
#private;
|
|
117
|
+
protected event: H3Event;
|
|
118
|
+
/**
|
|
119
|
+
* The request instance
|
|
120
|
+
*/
|
|
121
|
+
request: H3Event<EventHandlerRequest>['req'];
|
|
122
|
+
/**
|
|
123
|
+
* The response instance
|
|
124
|
+
*/
|
|
125
|
+
response: H3Event['res'];
|
|
126
|
+
/**
|
|
127
|
+
* The data to send to the client
|
|
128
|
+
*/
|
|
129
|
+
resource: R;
|
|
130
|
+
/**
|
|
131
|
+
* The final response data object
|
|
132
|
+
*/
|
|
133
|
+
body: BodyResource;
|
|
134
|
+
/**
|
|
135
|
+
* Flag to track if response should be sent automatically
|
|
136
|
+
*/
|
|
137
|
+
private shouldSend;
|
|
138
|
+
/**
|
|
139
|
+
* Flag to track if response has been sent
|
|
140
|
+
*/
|
|
141
|
+
private responseSent;
|
|
142
|
+
/**
|
|
143
|
+
* Declare that this includes R's properties
|
|
144
|
+
*/
|
|
145
|
+
[key: string]: any;
|
|
146
|
+
/**
|
|
147
|
+
* @param req The request instance
|
|
148
|
+
* @param res The response instance
|
|
149
|
+
* @param rsc The data to send to the client
|
|
150
|
+
*/
|
|
151
|
+
constructor(event: H3Event, rsc: R);
|
|
152
|
+
/**
|
|
153
|
+
* Return the data in the expected format
|
|
154
|
+
*
|
|
155
|
+
* @returns
|
|
156
|
+
*/
|
|
157
|
+
data(): Resource;
|
|
158
|
+
/**
|
|
159
|
+
* Build the response object
|
|
160
|
+
* @returns this
|
|
161
|
+
*/
|
|
162
|
+
json(): this;
|
|
163
|
+
/**
|
|
164
|
+
* Add context data to the response object
|
|
165
|
+
* @param data Context data
|
|
166
|
+
* @returns this
|
|
167
|
+
*/
|
|
168
|
+
additional<X extends {
|
|
122
169
|
[key: string]: any;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
json(): this;
|
|
140
|
-
/**
|
|
141
|
-
* Add context data to the response object
|
|
142
|
-
* @param data Context data
|
|
143
|
-
* @returns this
|
|
144
|
-
*/
|
|
145
|
-
additional<X extends {
|
|
146
|
-
[key: string]: any;
|
|
147
|
-
}>(data: X): this;
|
|
148
|
-
/**
|
|
149
|
-
* Send the output to the client
|
|
150
|
-
* @returns this
|
|
151
|
-
*/
|
|
152
|
-
send(): this;
|
|
153
|
-
/**
|
|
154
|
-
* Set the status code for this response
|
|
155
|
-
* @param code Status code
|
|
156
|
-
* @returns this
|
|
157
|
-
*/
|
|
158
|
-
status(code: number): this;
|
|
159
|
-
/**
|
|
160
|
-
* Check if send should be triggered automatically
|
|
161
|
-
*/
|
|
162
|
-
private checkSend;
|
|
170
|
+
}>(data: X): this;
|
|
171
|
+
/**
|
|
172
|
+
* Send the output to the client
|
|
173
|
+
* @returns this
|
|
174
|
+
*/
|
|
175
|
+
send(): this;
|
|
176
|
+
/**
|
|
177
|
+
* Set the status code for this response
|
|
178
|
+
* @param code Status code
|
|
179
|
+
* @returns this
|
|
180
|
+
*/
|
|
181
|
+
status(code: number): this;
|
|
182
|
+
/**
|
|
183
|
+
* Check if send should be triggered automatically
|
|
184
|
+
*/
|
|
185
|
+
private checkSend;
|
|
163
186
|
}
|
|
164
|
-
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/Resources/ApiResource.d.ts
|
|
165
189
|
declare function ApiResource(instance: JsonResource): JsonResource<any>;
|
|
166
|
-
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/Response.d.ts
|
|
167
192
|
declare class Response implements IResponse {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
193
|
+
/**
|
|
194
|
+
* The current app instance
|
|
195
|
+
*/
|
|
196
|
+
app: Application;
|
|
197
|
+
/**
|
|
198
|
+
* The current H3 H3Event instance
|
|
199
|
+
*/
|
|
200
|
+
private readonly event;
|
|
201
|
+
private statusCode;
|
|
202
|
+
private headers;
|
|
203
|
+
constructor(event: H3Event,
|
|
204
|
+
/**
|
|
205
|
+
* The current app instance
|
|
206
|
+
*/
|
|
207
|
+
app: Application);
|
|
208
|
+
/**
|
|
209
|
+
* Set HTTP status code.
|
|
210
|
+
*/
|
|
211
|
+
setStatusCode(code: number): this;
|
|
212
|
+
/**
|
|
213
|
+
* Set a header.
|
|
214
|
+
*/
|
|
215
|
+
setHeader(name: string, value: string): this;
|
|
216
|
+
html(content: string): string;
|
|
217
|
+
/**
|
|
218
|
+
* Send a JSON response.
|
|
219
|
+
*/
|
|
220
|
+
json<T = unknown>(data: T): T;
|
|
221
|
+
/**
|
|
222
|
+
* Send plain text.
|
|
223
|
+
*/
|
|
224
|
+
text(data: string): string;
|
|
225
|
+
/**
|
|
226
|
+
* Redirect to another URL.
|
|
227
|
+
*/
|
|
228
|
+
redirect(url: string, status?: number): string;
|
|
229
|
+
/**
|
|
230
|
+
* Apply headers before sending response.
|
|
231
|
+
*/
|
|
232
|
+
private applyHeaders;
|
|
233
|
+
/**
|
|
234
|
+
* Get the base event
|
|
235
|
+
*/
|
|
236
|
+
getEvent(): H3Event;
|
|
237
|
+
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
213
238
|
}
|
|
214
|
-
|
|
215
|
-
export { ApiResource, HttpServiceProvider, JsonResource, LogRequests, Middleware, Request,
|
|
239
|
+
//#endregion
|
|
240
|
+
export { ApiResource, FireCommand, HttpContext, HttpServiceProvider, JsonResource, LogRequests, Middleware, Request, Resource, Response };
|
|
241
|
+
//# sourceMappingURL=index.d.ts.map
|