@adonisjs/http-server 7.7.0 → 8.0.0-next.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/build/chunk-ASX56VAK.js +76 -0
- package/build/{chunk-6FSCILWX.js → chunk-HMYAZG76.js} +986 -616
- package/build/factories/http_context.d.ts +3 -3
- package/build/factories/http_server.d.ts +1 -1
- package/build/factories/main.d.ts +6 -6
- package/build/factories/main.js +87 -87
- package/build/factories/qs_parser_factory.d.ts +2 -2
- package/build/factories/request.d.ts +2 -2
- package/build/factories/response.d.ts +3 -3
- package/build/factories/router.d.ts +1 -1
- package/build/factories/server_factory.d.ts +2 -2
- package/build/factories/url_builder_factory.d.ts +25 -0
- package/build/index.d.ts +16 -15
- package/build/index.js +25 -23
- package/build/src/cookies/client.d.ts +2 -2
- package/build/src/cookies/parser.d.ts +2 -2
- package/build/src/cookies/serializer.d.ts +8 -2
- package/build/src/define_config.d.ts +1 -1
- package/build/src/define_middleware.d.ts +4 -3
- package/build/src/{exceptions.d.ts → errors.d.ts} +20 -6
- package/build/src/exception_handler.d.ts +4 -4
- package/build/src/helpers.d.ts +50 -15
- package/build/src/helpers.js +18 -0
- package/build/src/http_context/local_storage.d.ts +1 -1
- package/build/src/http_context/main.d.ts +5 -5
- package/build/src/qs.d.ts +3 -3
- package/build/src/redirect.d.ts +5 -5
- package/build/src/request.d.ts +12 -11
- package/build/src/response.d.ts +6 -6
- package/build/src/router/brisk.d.ts +6 -5
- package/build/src/router/executor.d.ts +4 -4
- package/build/src/router/factories/use_return_value.d.ts +6 -1
- package/build/src/router/group.d.ts +6 -6
- package/build/src/router/{lookup_store → legacy}/url_builder.d.ts +20 -4
- package/build/src/router/main.d.ts +117 -21
- package/build/src/router/resource.d.ts +4 -4
- package/build/src/router/route.d.ts +3 -3
- package/build/src/router/signed_url_builder.d.ts +15 -0
- package/build/src/router/store.d.ts +2 -2
- package/build/src/router/url_builder.d.ts +14 -0
- package/build/src/server/factories/middleware_handler.d.ts +4 -4
- package/build/src/server/factories/route_finder.d.ts +10 -0
- package/build/src/server/factories/write_response.d.ts +1 -1
- package/build/src/server/main.d.ts +12 -8
- package/build/src/tracing_channels.d.ts +23 -0
- package/build/src/types/main.d.ts +7 -7
- package/build/src/types/main.js +0 -1
- package/build/src/types/middleware.d.ts +35 -2
- package/build/src/types/request.d.ts +4 -0
- package/build/src/types/response.d.ts +1 -1
- package/build/src/types/route.d.ts +50 -49
- package/build/src/types/server.d.ts +5 -5
- package/build/src/types/tracing_channels.d.ts +6 -0
- package/build/src/types/url_builder.d.ts +147 -0
- package/build/src/utils.d.ts +28 -0
- package/package.json +45 -38
- package/build/chunk-6FSCILWX.js.map +0 -1
- package/build/factories/main.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/src/router/lookup_store/main.d.ts +0 -48
- package/build/src/router/lookup_store/route_finder.d.ts +0 -25
- package/build/src/router/parser.d.ts +0 -5
- package/build/src/server/factories/final_handler.d.ts +0 -10
- package/build/src/types/base.d.ts +0 -19
- package/build/src/types/main.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '@adonisjs/logger';
|
|
2
|
-
import type { Request } from '../src/request.
|
|
3
|
-
import type { Response } from '../src/response.
|
|
4
|
-
import { HttpContext } from '../src/http_context/main.
|
|
2
|
+
import type { Request } from '../src/request.ts';
|
|
3
|
+
import type { Response } from '../src/response.ts';
|
|
4
|
+
import { HttpContext } from '../src/http_context/main.ts';
|
|
5
5
|
type FactoryParameters = {
|
|
6
6
|
request: Request;
|
|
7
7
|
response: Response;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IncomingMessage, Server, ServerResponse } from 'node:http';
|
|
1
|
+
import { type IncomingMessage, type Server, type ServerResponse } from 'node:http';
|
|
2
2
|
export declare const httpServer: {
|
|
3
3
|
create(handler: (req: IncomingMessage, res: ServerResponse) => any | Promise<any>): Promise<{
|
|
4
4
|
server: Server;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
1
|
+
export { RouterFactory } from './router.ts';
|
|
2
|
+
export { RequestFactory } from './request.ts';
|
|
3
|
+
export { ResponseFactory } from './response.ts';
|
|
4
|
+
export { ServerFactory } from './server_factory.ts';
|
|
5
|
+
export { HttpContextFactory } from './http_context.ts';
|
|
6
|
+
export { QsParserFactory } from './qs_parser_factory.ts';
|
package/build/factories/main.js
CHANGED
|
@@ -6,16 +6,11 @@ import {
|
|
|
6
6
|
Router,
|
|
7
7
|
Server,
|
|
8
8
|
defineConfig
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-HMYAZG76.js";
|
|
10
|
+
import "../chunk-ASX56VAK.js";
|
|
10
11
|
|
|
11
|
-
// factories/
|
|
12
|
-
import {
|
|
13
|
-
import { LoggerFactory } from "@adonisjs/logger/factories";
|
|
14
|
-
|
|
15
|
-
// factories/request.ts
|
|
16
|
-
import { Socket } from "net";
|
|
17
|
-
import proxyAddr from "proxy-addr";
|
|
18
|
-
import { IncomingMessage, ServerResponse } from "http";
|
|
12
|
+
// factories/router.ts
|
|
13
|
+
import { AppFactory } from "@adonisjs/application/factories";
|
|
19
14
|
import { EncryptionFactory } from "@adonisjs/encryption/factories";
|
|
20
15
|
|
|
21
16
|
// factories/qs_parser_factory.ts
|
|
@@ -51,7 +46,43 @@ var QsParserFactory = class {
|
|
|
51
46
|
}
|
|
52
47
|
};
|
|
53
48
|
|
|
49
|
+
// factories/router.ts
|
|
50
|
+
var RouterFactory = class {
|
|
51
|
+
#parameters = {};
|
|
52
|
+
/**
|
|
53
|
+
* Returns an instance of the application class
|
|
54
|
+
*/
|
|
55
|
+
#getApp() {
|
|
56
|
+
return this.#parameters.app || new AppFactory().create(new URL("./app/", import.meta.url));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns an instance of the encryptor to encrypt
|
|
60
|
+
* signed URLs
|
|
61
|
+
*/
|
|
62
|
+
#createEncryption() {
|
|
63
|
+
return this.#parameters.encryption || new EncryptionFactory().create();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Merge factory params
|
|
67
|
+
*/
|
|
68
|
+
merge(params) {
|
|
69
|
+
Object.assign(this.#parameters, params);
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create router instance
|
|
74
|
+
*/
|
|
75
|
+
create() {
|
|
76
|
+
return new Router(this.#getApp(), this.#createEncryption(), new QsParserFactory().create());
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
54
80
|
// factories/request.ts
|
|
81
|
+
import { Socket } from "net";
|
|
82
|
+
import proxyAddr from "proxy-addr";
|
|
83
|
+
import { randomUUID } from "crypto";
|
|
84
|
+
import { IncomingMessage, ServerResponse } from "http";
|
|
85
|
+
import { EncryptionFactory as EncryptionFactory2 } from "@adonisjs/encryption/factories";
|
|
55
86
|
var RequestFactory = class {
|
|
56
87
|
#parameters = {};
|
|
57
88
|
/**
|
|
@@ -63,6 +94,9 @@ var RequestFactory = class {
|
|
|
63
94
|
trustProxy: proxyAddr.compile("loopback"),
|
|
64
95
|
subdomainOffset: 2,
|
|
65
96
|
generateRequestId: false,
|
|
97
|
+
createRequestId() {
|
|
98
|
+
return randomUUID();
|
|
99
|
+
},
|
|
66
100
|
...this.#parameters.config
|
|
67
101
|
};
|
|
68
102
|
}
|
|
@@ -90,7 +124,7 @@ var RequestFactory = class {
|
|
|
90
124
|
* signed URLs
|
|
91
125
|
*/
|
|
92
126
|
#createEncryption() {
|
|
93
|
-
return this.#parameters.encryption || new
|
|
127
|
+
return this.#parameters.encryption || new EncryptionFactory2().create();
|
|
94
128
|
}
|
|
95
129
|
/**
|
|
96
130
|
* Merge factory params
|
|
@@ -118,41 +152,6 @@ var RequestFactory = class {
|
|
|
118
152
|
import { Socket as Socket2 } from "net";
|
|
119
153
|
import { IncomingMessage as IncomingMessage2, ServerResponse as ServerResponse2 } from "http";
|
|
120
154
|
import { EncryptionFactory as EncryptionFactory3 } from "@adonisjs/encryption/factories";
|
|
121
|
-
|
|
122
|
-
// factories/router.ts
|
|
123
|
-
import { AppFactory } from "@adonisjs/application/factories";
|
|
124
|
-
import { EncryptionFactory as EncryptionFactory2 } from "@adonisjs/encryption/factories";
|
|
125
|
-
var RouterFactory = class {
|
|
126
|
-
#parameters = {};
|
|
127
|
-
/**
|
|
128
|
-
* Returns an instance of the application class
|
|
129
|
-
*/
|
|
130
|
-
#getApp() {
|
|
131
|
-
return this.#parameters.app || new AppFactory().create(new URL("./app/", import.meta.url));
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Returns an instance of the encryptor to encrypt
|
|
135
|
-
* signed URLs
|
|
136
|
-
*/
|
|
137
|
-
#createEncryption() {
|
|
138
|
-
return this.#parameters.encryption || new EncryptionFactory2().create();
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Merge factory params
|
|
142
|
-
*/
|
|
143
|
-
merge(params) {
|
|
144
|
-
Object.assign(this.#parameters, params);
|
|
145
|
-
return this;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Create router instance
|
|
149
|
-
*/
|
|
150
|
-
create() {
|
|
151
|
-
return new Router(this.#getApp(), this.#createEncryption(), new QsParserFactory().create());
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// factories/response.ts
|
|
156
155
|
var ResponseFactory = class {
|
|
157
156
|
#parameters = {};
|
|
158
157
|
/**
|
|
@@ -220,47 +219,6 @@ var ResponseFactory = class {
|
|
|
220
219
|
}
|
|
221
220
|
};
|
|
222
221
|
|
|
223
|
-
// factories/http_context.ts
|
|
224
|
-
var HttpContextFactory = class {
|
|
225
|
-
#parameters = {};
|
|
226
|
-
/**
|
|
227
|
-
* Returns the request class instance
|
|
228
|
-
*/
|
|
229
|
-
#createRequest() {
|
|
230
|
-
return this.#parameters.request || new RequestFactory().create();
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Returns the response class instance
|
|
234
|
-
*/
|
|
235
|
-
#createResponse() {
|
|
236
|
-
return this.#parameters.response || new ResponseFactory().create();
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Returns an instance of the logger class
|
|
240
|
-
*/
|
|
241
|
-
#createLogger() {
|
|
242
|
-
return this.#parameters.logger || new LoggerFactory().create();
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Merge factory params
|
|
246
|
-
*/
|
|
247
|
-
merge(params) {
|
|
248
|
-
Object.assign(this.#parameters, params);
|
|
249
|
-
return this;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Create request
|
|
253
|
-
*/
|
|
254
|
-
create() {
|
|
255
|
-
return new HttpContext(
|
|
256
|
-
this.#createRequest(),
|
|
257
|
-
this.#createResponse(),
|
|
258
|
-
this.#createLogger(),
|
|
259
|
-
new Container().createResolver()
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
|
|
264
222
|
// factories/server_factory.ts
|
|
265
223
|
import { Logger } from "@adonisjs/logger";
|
|
266
224
|
import { Emitter } from "@adonisjs/events";
|
|
@@ -319,6 +277,49 @@ var ServerFactory = class {
|
|
|
319
277
|
);
|
|
320
278
|
}
|
|
321
279
|
};
|
|
280
|
+
|
|
281
|
+
// factories/http_context.ts
|
|
282
|
+
import { Container } from "@adonisjs/fold";
|
|
283
|
+
import { LoggerFactory } from "@adonisjs/logger/factories";
|
|
284
|
+
var HttpContextFactory = class {
|
|
285
|
+
#parameters = {};
|
|
286
|
+
/**
|
|
287
|
+
* Returns the request class instance
|
|
288
|
+
*/
|
|
289
|
+
#createRequest() {
|
|
290
|
+
return this.#parameters.request || new RequestFactory().create();
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Returns the response class instance
|
|
294
|
+
*/
|
|
295
|
+
#createResponse() {
|
|
296
|
+
return this.#parameters.response || new ResponseFactory().create();
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Returns an instance of the logger class
|
|
300
|
+
*/
|
|
301
|
+
#createLogger() {
|
|
302
|
+
return this.#parameters.logger || new LoggerFactory().create();
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Merge factory params
|
|
306
|
+
*/
|
|
307
|
+
merge(params) {
|
|
308
|
+
Object.assign(this.#parameters, params);
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Create request
|
|
313
|
+
*/
|
|
314
|
+
create() {
|
|
315
|
+
return new HttpContext(
|
|
316
|
+
this.#createRequest(),
|
|
317
|
+
this.#createResponse(),
|
|
318
|
+
this.#createLogger(),
|
|
319
|
+
new Container().createResolver()
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
322
323
|
export {
|
|
323
324
|
HttpContextFactory,
|
|
324
325
|
QsParserFactory,
|
|
@@ -327,4 +328,3 @@ export {
|
|
|
327
328
|
RouterFactory,
|
|
328
329
|
ServerFactory
|
|
329
330
|
};
|
|
330
|
-
//# sourceMappingURL=main.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Qs } from '../src/qs.
|
|
2
|
-
import type { QSParserConfig } from '../src/types/qs.
|
|
1
|
+
import { Qs } from '../src/qs.ts';
|
|
2
|
+
import type { QSParserConfig } from '../src/types/qs.ts';
|
|
3
3
|
/**
|
|
4
4
|
* QS Parser factory is used to generate the query string
|
|
5
5
|
* parser for testing
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
import { Request } from '../src/request.
|
|
4
|
-
import { RequestConfig } from '../src/types/request.
|
|
3
|
+
import { Request } from '../src/request.ts';
|
|
4
|
+
import { type RequestConfig } from '../src/types/request.ts';
|
|
5
5
|
type FactoryParameters = {
|
|
6
6
|
url: string;
|
|
7
7
|
method: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
import { Response } from '../src/response.
|
|
4
|
-
import { Router } from '../src/router/main.
|
|
5
|
-
import { ResponseConfig } from '../src/types/response.
|
|
3
|
+
import { Response } from '../src/response.ts';
|
|
4
|
+
import { type Router } from '../src/router/main.ts';
|
|
5
|
+
import { type ResponseConfig } from '../src/types/response.ts';
|
|
6
6
|
type FactoryParameters = {
|
|
7
7
|
req: IncomingMessage;
|
|
8
8
|
res: ServerResponse;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
2
|
import type { Application } from '@adonisjs/application';
|
|
3
|
-
import { Router } from '../src/router/main.
|
|
3
|
+
import { Router } from '../src/router/main.ts';
|
|
4
4
|
type FactoryParameters = {
|
|
5
5
|
app: Application<any>;
|
|
6
6
|
encryption: Encryption;
|
|
@@ -2,8 +2,8 @@ import { Logger } from '@adonisjs/logger';
|
|
|
2
2
|
import { Emitter } from '@adonisjs/events';
|
|
3
3
|
import type { Encryption } from '@adonisjs/encryption';
|
|
4
4
|
import type { Application } from '@adonisjs/application';
|
|
5
|
-
import { Server } from '../src/server/main.
|
|
6
|
-
import type { ServerConfig } from '../src/types/server.
|
|
5
|
+
import { Server } from '../src/server/main.ts';
|
|
6
|
+
import type { ServerConfig } from '../src/types/server.ts';
|
|
7
7
|
type FactoryParameters = {
|
|
8
8
|
app: Application<any>;
|
|
9
9
|
logger: Logger;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Encryption } from '@adonisjs/encryption';
|
|
2
|
+
import type { Router } from '../src/router/main.ts';
|
|
3
|
+
import { type LookupList } from '../src/types/url_builder.ts';
|
|
4
|
+
type FactoryParameters = {
|
|
5
|
+
router: Router;
|
|
6
|
+
encryption: Encryption;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* URLBuilderFactory is used to create route and signed route helpers
|
|
10
|
+
*/
|
|
11
|
+
export declare class URLBuilderFactory<Routes extends LookupList> {
|
|
12
|
+
#private;
|
|
13
|
+
/**
|
|
14
|
+
* Merge factory params
|
|
15
|
+
*/
|
|
16
|
+
merge(params: Partial<FactoryParameters>): this;
|
|
17
|
+
/**
|
|
18
|
+
* Create URL builder helpers
|
|
19
|
+
*/
|
|
20
|
+
create(): {
|
|
21
|
+
urlFor: import("../src/types/url_builder.ts").UrlFor<Routes>;
|
|
22
|
+
signedUrlFor: import("../src/types/url_builder.ts").UrlFor<Routes, import("../src/types/url_builder.ts").SignedURLOptions>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/build/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { Redirect } from './src/redirect.
|
|
5
|
-
export { Server } from './src/server/main.
|
|
6
|
-
export { Router } from './src/router/main.
|
|
7
|
-
export { Route } from './src/router/route.
|
|
8
|
-
export
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export { ExceptionHandler } from './src/exception_handler.
|
|
1
|
+
export * as errors from './src/errors.ts';
|
|
2
|
+
export { Request } from './src/request.ts';
|
|
3
|
+
export { Response } from './src/response.ts';
|
|
4
|
+
export { Redirect } from './src/redirect.ts';
|
|
5
|
+
export { Server } from './src/server/main.ts';
|
|
6
|
+
export { Router } from './src/router/main.ts';
|
|
7
|
+
export { Route } from './src/router/route.ts';
|
|
8
|
+
export { BriskRoute } from './src/router/brisk.ts';
|
|
9
|
+
export { RouteGroup } from './src/router/group.ts';
|
|
10
|
+
export { defineConfig } from './src/define_config.ts';
|
|
11
|
+
export { CookieClient } from './src/cookies/client.ts';
|
|
12
|
+
export { HttpContext } from './src/http_context/main.ts';
|
|
13
|
+
export { RouteResource } from './src/router/resource.ts';
|
|
14
|
+
export { ResponseStatus } from './src/response_status.ts';
|
|
15
|
+
export { ExceptionHandler } from './src/exception_handler.ts';
|
|
16
|
+
export * as tracingChannels from './src/tracing_channels.ts';
|
package/build/index.js
CHANGED
|
@@ -15,10 +15,13 @@ import {
|
|
|
15
15
|
RouteResource,
|
|
16
16
|
Router,
|
|
17
17
|
Server,
|
|
18
|
+
canWriteResponseBody,
|
|
18
19
|
defineConfig,
|
|
19
|
-
|
|
20
|
-
parseRange
|
|
21
|
-
|
|
20
|
+
errors_exports,
|
|
21
|
+
parseRange,
|
|
22
|
+
tracing_channels_exports
|
|
23
|
+
} from "./chunk-HMYAZG76.js";
|
|
24
|
+
import "./chunk-ASX56VAK.js";
|
|
22
25
|
|
|
23
26
|
// src/exception_handler.ts
|
|
24
27
|
import is from "@sindresorhus/is";
|
|
@@ -149,9 +152,9 @@ var ExceptionHandler = class extends Macroable {
|
|
|
149
152
|
*/
|
|
150
153
|
async renderErrorAsJSON(error, ctx) {
|
|
151
154
|
if (this.isDebuggingEnabled(ctx)) {
|
|
152
|
-
const {
|
|
153
|
-
const json = await new Youch(
|
|
154
|
-
ctx.response.status(error.status).send(json
|
|
155
|
+
const { Youch } = await import("youch");
|
|
156
|
+
const json = await new Youch().toJSON(error);
|
|
157
|
+
ctx.response.status(error.status).send(json);
|
|
155
158
|
return;
|
|
156
159
|
}
|
|
157
160
|
ctx.response.status(error.status).send({ message: error.message });
|
|
@@ -161,9 +164,9 @@ var ExceptionHandler = class extends Macroable {
|
|
|
161
164
|
*/
|
|
162
165
|
async renderErrorAsJSONAPI(error, ctx) {
|
|
163
166
|
if (this.isDebuggingEnabled(ctx)) {
|
|
164
|
-
const {
|
|
165
|
-
const json = await new Youch(
|
|
166
|
-
ctx.response.status(error.status).send(json
|
|
167
|
+
const { Youch } = await import("youch");
|
|
168
|
+
const json = await new Youch().toJSON(error);
|
|
169
|
+
ctx.response.status(error.status).send(json);
|
|
167
170
|
return;
|
|
168
171
|
}
|
|
169
172
|
ctx.response.status(error.status).send({
|
|
@@ -180,9 +183,18 @@ var ExceptionHandler = class extends Macroable {
|
|
|
180
183
|
* Renders an error to HTML response
|
|
181
184
|
*/
|
|
182
185
|
async renderErrorAsHTML(error, ctx) {
|
|
186
|
+
const statusPages = this.#expandStatusPages();
|
|
187
|
+
if (this.renderStatusPages && statusPages[error.status]) {
|
|
188
|
+
const statusPageResponse = await statusPages[error.status](error, ctx);
|
|
189
|
+
if (canWriteResponseBody(statusPageResponse, ctx)) {
|
|
190
|
+
return ctx.response.safeStatus(error.status).send(statusPageResponse);
|
|
191
|
+
}
|
|
192
|
+
return statusPageResponse;
|
|
193
|
+
}
|
|
183
194
|
if (this.isDebuggingEnabled(ctx)) {
|
|
184
|
-
const {
|
|
185
|
-
const html = await new Youch(
|
|
195
|
+
const { Youch } = await import("youch");
|
|
196
|
+
const html = await new Youch().toHTML(error, {
|
|
197
|
+
request: ctx.request.request,
|
|
186
198
|
cspNonce: "nonce" in ctx.response ? ctx.response.nonce : void 0
|
|
187
199
|
});
|
|
188
200
|
ctx.response.status(error.status).send(html);
|
|
@@ -288,16 +300,6 @@ var ExceptionHandler = class extends Macroable {
|
|
|
288
300
|
if (httpError.code === "E_VALIDATION_ERROR" && "messages" in httpError) {
|
|
289
301
|
return this.renderValidationError(httpError, ctx);
|
|
290
302
|
}
|
|
291
|
-
const statusPages = this.#expandStatusPages();
|
|
292
|
-
if (this.renderStatusPages && statusPages[httpError.status]) {
|
|
293
|
-
const statusPageResponse = await statusPages[httpError.status](httpError, ctx);
|
|
294
|
-
if (statusPageResponse !== void 0 && // Return value is explicitly defined
|
|
295
|
-
!ctx.response.hasLazyBody && // Lazy body is not set
|
|
296
|
-
statusPageResponse !== ctx.response) {
|
|
297
|
-
return ctx.response.safeStatus(httpError.status).send(statusPageResponse);
|
|
298
|
-
}
|
|
299
|
-
return statusPageResponse;
|
|
300
|
-
}
|
|
301
303
|
return this.renderError(httpError, ctx);
|
|
302
304
|
}
|
|
303
305
|
};
|
|
@@ -316,6 +318,6 @@ export {
|
|
|
316
318
|
Router,
|
|
317
319
|
Server,
|
|
318
320
|
defineConfig,
|
|
319
|
-
|
|
321
|
+
errors_exports as errors,
|
|
322
|
+
tracing_channels_exports as tracingChannels
|
|
320
323
|
};
|
|
321
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -17,7 +17,7 @@ export declare class CookieClient {
|
|
|
17
17
|
/**
|
|
18
18
|
* Encode a key value pair to be sent in the cookie header
|
|
19
19
|
*/
|
|
20
|
-
encode(_: string, value: any): string | null;
|
|
20
|
+
encode(_: string, value: any, stringify?: boolean): string | null;
|
|
21
21
|
/**
|
|
22
22
|
* Unsign a signed cookie value
|
|
23
23
|
*/
|
|
@@ -29,7 +29,7 @@ export declare class CookieClient {
|
|
|
29
29
|
/**
|
|
30
30
|
* Decode an encoded cookie value
|
|
31
31
|
*/
|
|
32
|
-
decode(_: string, value: string): any;
|
|
32
|
+
decode(_: string, value: string, stringified?: boolean): any;
|
|
33
33
|
/**
|
|
34
34
|
* Parse response cookie
|
|
35
35
|
*/
|
|
@@ -14,10 +14,10 @@ export declare class CookieParser {
|
|
|
14
14
|
constructor(cookieHeader: string, encryption: Encryption);
|
|
15
15
|
/**
|
|
16
16
|
* Attempts to decode a cookie by the name. When calling this method,
|
|
17
|
-
* you are assuming that the cookie was just
|
|
17
|
+
* you are assuming that the cookie was just stringified in the first
|
|
18
18
|
* place and not signed or encrypted.
|
|
19
19
|
*/
|
|
20
|
-
decode(key: string,
|
|
20
|
+
decode(key: string, stringified?: boolean): any | null;
|
|
21
21
|
/**
|
|
22
22
|
* Attempts to unsign a cookie by the name. When calling this method,
|
|
23
23
|
* you are assuming that the cookie was signed in the first place.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
|
-
import type { CookieOptions } from '../types/response.
|
|
2
|
+
import type { CookieOptions } from '../types/response.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Cookies serializer is used to serialize a value to be set on the `Set-Cookie`
|
|
5
5
|
* header. You can `encode`, `sign` on `encrypt` cookies using the serializer
|
|
@@ -12,14 +12,20 @@ export declare class CookieSerializer {
|
|
|
12
12
|
* Encodes value as a plain cookie. By default, the plain value will be converted
|
|
13
13
|
* to a string using "JSON.stringify" method and then encoded as a base64 string.
|
|
14
14
|
*
|
|
15
|
-
* You can disable
|
|
15
|
+
* You can disable cookie stringifaction by setting `options.stringify = false`.
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
18
|
* serializer.encode('name', 'virk')
|
|
19
|
+
* serializer.encode('name', 'virk', { stringify: false })
|
|
19
20
|
* ```
|
|
20
21
|
*/
|
|
21
22
|
encode(key: string, value: any, options?: Partial<CookieOptions & {
|
|
23
|
+
/**
|
|
24
|
+
* @depreacted
|
|
25
|
+
* Instead use stringify option
|
|
26
|
+
*/
|
|
22
27
|
encode: boolean;
|
|
28
|
+
stringify: boolean;
|
|
23
29
|
}>): string | null;
|
|
24
30
|
/**
|
|
25
31
|
* Sign a key-value pair to a signed cookie. The signed value has a
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { LazyImport, UnWrapLazyImport } from '
|
|
2
|
-
import type { GetMiddlewareArgs, MiddlewareAsClass, ParsedGlobalMiddleware } from './types/middleware.
|
|
1
|
+
import type { LazyImport, UnWrapLazyImport } from '@poppinss/utils/types';
|
|
2
|
+
import type { GetMiddlewareArgs, MiddlewareAsClass, ParsedGlobalMiddleware } from './types/middleware.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Define an collection of named middleware. The collection gets converted
|
|
5
5
|
* into a collection of factory functions. Calling the function returns
|
|
6
6
|
* a reference to the executable middleware.
|
|
7
7
|
*/
|
|
8
|
-
export declare function defineNamedMiddleware<NamedMiddleware extends Record<string
|
|
8
|
+
export declare function defineNamedMiddleware<NamedMiddleware extends Record<string, LazyImport<MiddlewareAsClass>>>(collection: NamedMiddleware): { [K in keyof NamedMiddleware]: <Args extends GetMiddlewareArgs<UnWrapLazyImport<NamedMiddleware[K]>>>(...args: Args) => {
|
|
9
9
|
name: K;
|
|
10
|
+
reference: LazyImport<MiddlewareAsClass> | MiddlewareAsClass;
|
|
10
11
|
args: Args[0];
|
|
11
12
|
handle: ParsedGlobalMiddleware["handle"];
|
|
12
13
|
}; };
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import { Exception } from '@poppinss/utils';
|
|
2
|
-
import type { HttpContext } from './http_context/main.
|
|
1
|
+
import { Exception } from '@poppinss/utils/exception';
|
|
2
|
+
import type { HttpContext } from './http_context/main.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Thrown when unable to find a matching route for the given request
|
|
5
|
+
*/
|
|
3
6
|
export declare const E_ROUTE_NOT_FOUND: new (args: [method: string, url: string], options?: ErrorOptions) => Exception;
|
|
7
|
+
/**
|
|
8
|
+
* Thrown when unable to lookup a route by its identifier.
|
|
9
|
+
*/
|
|
4
10
|
export declare const E_CANNOT_LOOKUP_ROUTE: new (args: [routeIdentifier: string], options?: ErrorOptions) => Exception;
|
|
11
|
+
/**
|
|
12
|
+
* A generic HTTP exception to convert errors to HTTP response
|
|
13
|
+
*/
|
|
5
14
|
export declare const E_HTTP_EXCEPTION: {
|
|
6
15
|
new (message?: string, options?: ErrorOptions & {
|
|
7
16
|
code?: string;
|
|
@@ -13,7 +22,7 @@ export declare const E_HTTP_EXCEPTION: {
|
|
|
13
22
|
code?: string;
|
|
14
23
|
status: number;
|
|
15
24
|
toString(): string;
|
|
16
|
-
|
|
25
|
+
get [Symbol.toStringTag](): string;
|
|
17
26
|
message: string;
|
|
18
27
|
stack?: string;
|
|
19
28
|
cause?: unknown;
|
|
@@ -29,7 +38,7 @@ export declare const E_HTTP_EXCEPTION: {
|
|
|
29
38
|
code?: string;
|
|
30
39
|
status: number;
|
|
31
40
|
toString(): string;
|
|
32
|
-
|
|
41
|
+
get [Symbol.toStringTag](): string;
|
|
33
42
|
message: string;
|
|
34
43
|
stack?: string;
|
|
35
44
|
cause?: unknown;
|
|
@@ -37,10 +46,14 @@ export declare const E_HTTP_EXCEPTION: {
|
|
|
37
46
|
help?: string;
|
|
38
47
|
status?: number;
|
|
39
48
|
message?: string;
|
|
49
|
+
isError(error: unknown): error is Error;
|
|
40
50
|
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
41
51
|
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
42
52
|
stackTraceLimit: number;
|
|
43
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Thrown when the "response.abort" method is called
|
|
56
|
+
*/
|
|
44
57
|
export declare const E_HTTP_REQUEST_ABORTED: {
|
|
45
58
|
new (message?: string, options?: ErrorOptions & {
|
|
46
59
|
code?: string;
|
|
@@ -53,7 +66,7 @@ export declare const E_HTTP_REQUEST_ABORTED: {
|
|
|
53
66
|
code?: string;
|
|
54
67
|
status: number;
|
|
55
68
|
toString(): string;
|
|
56
|
-
|
|
69
|
+
get [Symbol.toStringTag](): string;
|
|
57
70
|
message: string;
|
|
58
71
|
stack?: string;
|
|
59
72
|
cause?: unknown;
|
|
@@ -69,7 +82,7 @@ export declare const E_HTTP_REQUEST_ABORTED: {
|
|
|
69
82
|
code?: string;
|
|
70
83
|
status: number;
|
|
71
84
|
toString(): string;
|
|
72
|
-
|
|
85
|
+
get [Symbol.toStringTag](): string;
|
|
73
86
|
message: string;
|
|
74
87
|
stack?: string;
|
|
75
88
|
cause?: unknown;
|
|
@@ -77,6 +90,7 @@ export declare const E_HTTP_REQUEST_ABORTED: {
|
|
|
77
90
|
help?: string;
|
|
78
91
|
status?: number;
|
|
79
92
|
message?: string;
|
|
93
|
+
isError(error: unknown): error is Error;
|
|
80
94
|
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
81
95
|
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
82
96
|
stackTraceLimit: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
2
|
import type { Level } from '@adonisjs/logger/types';
|
|
3
|
-
import type { HttpContext } from './http_context/main.
|
|
4
|
-
import type { HttpError, StatusPageRange, StatusPageRenderer } from './types/server.
|
|
3
|
+
import type { HttpContext } from './http_context/main.ts';
|
|
4
|
+
import type { HttpError, StatusPageRange, StatusPageRenderer } from './types/server.ts';
|
|
5
5
|
/**
|
|
6
6
|
* The base HTTP exception handler one can inherit from to handle
|
|
7
7
|
* HTTP exceptions.
|
|
@@ -79,7 +79,7 @@ export declare class ExceptionHandler extends Macroable {
|
|
|
79
79
|
/**
|
|
80
80
|
* Renders an error to HTML response
|
|
81
81
|
*/
|
|
82
|
-
renderErrorAsHTML(error: HttpError, ctx: HttpContext): Promise<
|
|
82
|
+
renderErrorAsHTML(error: HttpError, ctx: HttpContext): Promise<any>;
|
|
83
83
|
/**
|
|
84
84
|
* Renders the validation error message to a JSON
|
|
85
85
|
* response
|
|
@@ -97,7 +97,7 @@ export declare class ExceptionHandler extends Macroable {
|
|
|
97
97
|
/**
|
|
98
98
|
* Renders the error to response
|
|
99
99
|
*/
|
|
100
|
-
renderError(error: HttpError, ctx: HttpContext): Promise<
|
|
100
|
+
renderError(error: HttpError, ctx: HttpContext): Promise<any>;
|
|
101
101
|
/**
|
|
102
102
|
* Renders the validation error to response
|
|
103
103
|
*/
|