@adonisjs/http-server 7.0.0-0 → 7.0.0-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.
Files changed (107) hide show
  1. package/build/factories/http_context.d.ts +25 -0
  2. package/build/factories/http_context.js +51 -0
  3. package/build/factories/http_server.d.ts +8 -0
  4. package/build/factories/http_server.js +26 -0
  5. package/build/factories/main.d.ts +6 -149
  6. package/build/factories/main.js +14 -331
  7. package/build/factories/qs_parser_factory.d.ts +20 -0
  8. package/build/factories/qs_parser_factory.js +44 -0
  9. package/build/factories/request.d.ts +29 -0
  10. package/build/factories/request.js +73 -0
  11. package/build/factories/response.d.ts +29 -0
  12. package/build/factories/response.js +77 -0
  13. package/build/factories/router.d.ts +23 -0
  14. package/build/factories/router.js +45 -0
  15. package/build/factories/server_factory.d.ts +29 -0
  16. package/build/factories/server_factory.js +65 -0
  17. package/build/index.d.ts +14 -272
  18. package/build/index.js +22 -308
  19. package/build/src/cookies/client.d.ts +37 -0
  20. package/build/src/cookies/client.js +84 -0
  21. package/build/src/cookies/drivers/encrypted.d.ts +16 -0
  22. package/build/src/cookies/drivers/encrypted.js +36 -0
  23. package/build/src/cookies/drivers/plain.d.ts +15 -0
  24. package/build/src/cookies/drivers/plain.js +33 -0
  25. package/build/src/cookies/drivers/signed.d.ts +16 -0
  26. package/build/src/cookies/drivers/signed.js +36 -0
  27. package/build/src/cookies/parser.d.ts +37 -0
  28. package/build/src/cookies/parser.js +167 -0
  29. package/build/src/cookies/serializer.d.ts +33 -0
  30. package/build/src/cookies/serializer.js +79 -0
  31. package/build/src/debug.d.ts +3 -0
  32. package/build/src/debug.js +10 -0
  33. package/build/src/define_config.d.ts +9 -0
  34. package/build/src/define_config.js +68 -0
  35. package/build/src/define_middleware.d.ts +11 -0
  36. package/build/src/define_middleware.js +35 -0
  37. package/build/src/exception_handler.d.ts +113 -0
  38. package/build/src/exception_handler.js +306 -0
  39. package/build/src/exceptions.d.ts +84 -0
  40. package/build/src/exceptions.js +38 -0
  41. package/build/src/helpers.d.ts +23 -0
  42. package/build/src/helpers.js +105 -0
  43. package/build/src/http_context/local_storage.d.ts +12 -0
  44. package/build/src/http_context/local_storage.js +39 -0
  45. package/build/src/http_context/main.d.ts +58 -0
  46. package/build/src/http_context/main.js +105 -0
  47. package/build/src/qs.d.ts +11 -0
  48. package/build/src/qs.js +25 -0
  49. package/build/src/redirect.d.ts +42 -0
  50. package/build/src/redirect.js +140 -0
  51. package/build/src/request.d.ts +565 -0
  52. package/build/src/request.js +865 -0
  53. package/build/src/response.d.ts +620 -0
  54. package/build/src/response.js +1208 -0
  55. package/build/src/router/brisk.d.ts +42 -0
  56. package/build/src/router/brisk.js +85 -0
  57. package/build/src/router/executor.d.ts +9 -0
  58. package/build/src/router/executor.js +30 -0
  59. package/build/src/router/factories/use_return_value.d.ts +6 -0
  60. package/build/src/router/factories/use_return_value.js +22 -0
  61. package/build/src/router/group.d.ts +65 -0
  62. package/build/src/router/group.js +207 -0
  63. package/build/src/router/lookup_store/main.d.ts +49 -0
  64. package/build/src/router/lookup_store/main.js +86 -0
  65. package/build/src/router/lookup_store/route_finder.d.ts +21 -0
  66. package/build/src/router/lookup_store/route_finder.js +49 -0
  67. package/build/src/router/lookup_store/url_builder.d.ts +52 -0
  68. package/build/src/router/lookup_store/url_builder.js +209 -0
  69. package/build/src/router/main.d.ts +128 -0
  70. package/build/src/router/main.js +316 -0
  71. package/build/src/router/matchers.d.ts +27 -0
  72. package/build/src/router/matchers.js +36 -0
  73. package/build/src/router/parser.d.ts +5 -0
  74. package/build/src/router/parser.js +17 -0
  75. package/build/src/router/resource.d.ts +54 -0
  76. package/build/src/router/resource.js +216 -0
  77. package/build/src/router/route.d.ts +92 -0
  78. package/build/src/router/route.js +293 -0
  79. package/build/src/router/store.d.ts +66 -0
  80. package/build/src/router/store.js +195 -0
  81. package/build/src/server/factories/final_handler.d.ts +10 -0
  82. package/build/src/server/factories/final_handler.js +30 -0
  83. package/build/src/server/factories/middleware_handler.d.ts +8 -0
  84. package/build/src/server/factories/middleware_handler.js +16 -0
  85. package/build/src/server/factories/write_response.d.ts +6 -0
  86. package/build/src/server/factories/write_response.js +24 -0
  87. package/build/{main-29eaaee4.d.ts → src/server/main.d.ts} +18 -13
  88. package/build/src/server/main.js +292 -0
  89. package/build/src/types/base.d.ts +19 -0
  90. package/build/src/types/base.js +9 -0
  91. package/build/src/types/main.d.ts +7 -14
  92. package/build/src/types/main.js +15 -0
  93. package/build/src/types/middleware.d.ts +35 -0
  94. package/build/src/types/middleware.js +9 -0
  95. package/build/src/types/qs.d.ts +68 -0
  96. package/build/src/types/qs.js +9 -0
  97. package/build/src/types/request.d.ts +39 -0
  98. package/build/src/types/request.js +9 -0
  99. package/build/src/types/response.d.ts +45 -0
  100. package/build/src/types/response.js +9 -0
  101. package/build/src/types/route.d.ts +166 -0
  102. package/build/src/types/route.js +9 -0
  103. package/build/src/types/server.d.ts +72 -0
  104. package/build/src/types/server.js +9 -0
  105. package/package.json +6 -3
  106. package/build/chunk-XX72ATFY.js +0 -4388
  107. package/build/main-e5b46c83.d.ts +0 -2210
@@ -1,17 +1,24 @@
1
- import { Logger } from '@adonisjs/logger';
2
- import { Emitter } from '@adonisjs/events';
3
- import { Encryption } from '@adonisjs/encryption';
4
- import { Server as Server$2 } from 'node:https';
5
- import { Application } from '@adonisjs/application';
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import type { Logger } from '@adonisjs/logger';
4
+ import type { Emitter } from '@adonisjs/events';
5
+ import type { Encryption } from '@adonisjs/encryption';
6
+ import type { Server as HttpsServer } from 'node:https';
7
+ import type { Application } from '@adonisjs/application';
6
8
  import { ContainerResolver } from '@adonisjs/fold';
7
- import { Server as Server$1, IncomingMessage, ServerResponse } from 'node:http';
8
- import { S as ServerConfig, M as MiddlewareAsClass, T as TestingMiddlewarePipeline, L as LazyImport, E as ErrorHandlerAsAClass, R as Router, a as Request, b as Response, H as HttpContext } from './main-e5b46c83.js';
9
-
9
+ import type { ServerResponse, IncomingMessage, Server as HttpServer } from 'node:http';
10
+ import type { LazyImport } from '../types/base.js';
11
+ import type { MiddlewareAsClass } from '../types/middleware.js';
12
+ import type { ServerConfig, ErrorHandlerAsAClass, TestingMiddlewarePipeline } from '../types/server.js';
13
+ import { Request } from '../request.js';
14
+ import { Response } from '../response.js';
15
+ import { Router } from '../router/main.js';
16
+ import { HttpContext } from '../http_context/main.js';
10
17
  /**
11
18
  * The HTTP server implementation to handle incoming requests and respond using the
12
19
  * registered routes.
13
20
  */
14
- declare class Server {
21
+ export declare class Server {
15
22
  #private;
16
23
  /**
17
24
  * Know if async local storage is enabled or not.
@@ -43,12 +50,12 @@ declare class Server {
43
50
  /**
44
51
  * Set the HTTP server instance used to listen for requests.
45
52
  */
46
- setNodeServer(server: Server$1 | Server$2): void;
53
+ setNodeServer(server: HttpServer | HttpsServer): void;
47
54
  /**
48
55
  * Returns reference to the underlying HTTP server
49
56
  * in use
50
57
  */
51
- getNodeServer(): Server$1<typeof IncomingMessage, typeof ServerResponse> | Server$2<typeof IncomingMessage, typeof ServerResponse> | undefined;
58
+ getNodeServer(): HttpServer<typeof IncomingMessage, typeof ServerResponse> | HttpsServer<typeof IncomingMessage, typeof ServerResponse> | undefined;
52
59
  /**
53
60
  * Returns reference to the router instance used
54
61
  * by the server.
@@ -71,5 +78,3 @@ declare class Server {
71
78
  */
72
79
  handle(req: IncomingMessage, res: ServerResponse): Promise<any>;
73
80
  }
74
-
75
- export { Server as S };
@@ -0,0 +1,292 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import onFinished from 'on-finished';
10
+ import Middleware from '@poppinss/middleware';
11
+ import { moduleCaller, moduleImporter } from '@adonisjs/fold';
12
+ import { Qs } from '../qs.js';
13
+ import debug from '../debug.js';
14
+ import { Request } from '../request.js';
15
+ import { Response } from '../response.js';
16
+ import { Router } from '../router/main.js';
17
+ import { HttpContext } from '../http_context/main.js';
18
+ import { finalHandler } from './factories/final_handler.js';
19
+ import { writeResponse } from './factories/write_response.js';
20
+ import { asyncLocalStorage } from '../http_context/local_storage.js';
21
+ import { middlewareHandler } from './factories/middleware_handler.js';
22
+ /**
23
+ * The HTTP server implementation to handle incoming requests and respond using the
24
+ * registered routes.
25
+ */
26
+ export class Server {
27
+ /**
28
+ * The default error handler to use
29
+ */
30
+ #defaultErrorHandler = {
31
+ report() { },
32
+ handle(error, ctx) {
33
+ ctx.response.status(error.status || 500).send(error.message || 'Internal server error');
34
+ },
35
+ };
36
+ /**
37
+ * Logger instance, a child logger is added
38
+ * to the context to have request specific
39
+ * logging capabilities.
40
+ */
41
+ #logger;
42
+ /**
43
+ * Registered error handler (if any)
44
+ */
45
+ #errorHandler;
46
+ /**
47
+ * Resolved error handler is an instance of the lazily imported error
48
+ * handler class.
49
+ */
50
+ #resolvedErrorHandler = this.#defaultErrorHandler;
51
+ /**
52
+ * Emitter is required to notify when a request finishes
53
+ */
54
+ #emitter;
55
+ /**
56
+ * The application instance to be shared with the router
57
+ */
58
+ #app;
59
+ /**
60
+ * The encryption instance to be shared with the router
61
+ */
62
+ #encryption;
63
+ /**
64
+ * Server config
65
+ */
66
+ #config;
67
+ /**
68
+ * Query string parser used by the server
69
+ */
70
+ #qsParser;
71
+ /**
72
+ * Server middleware stack runs on every incoming HTTP request
73
+ */
74
+ #serverMiddlewareStack;
75
+ /**
76
+ * Reference to the router used by the server
77
+ */
78
+ #router;
79
+ /**
80
+ * Reference to the underlying Node HTTP server in use
81
+ */
82
+ #nodeHttpServer;
83
+ /**
84
+ * Middleware store to be shared with the routes
85
+ */
86
+ #middleware = [];
87
+ /**
88
+ * The request error response is attached to the middleware
89
+ * pipeline to intercept errors and invoke the user
90
+ * registered error handler.
91
+ *
92
+ * We share this with the route middleware pipeline as well,
93
+ * so that it does not throw any exceptions
94
+ */
95
+ #requestErrorResponder = (error, ctx) => {
96
+ this.#resolvedErrorHandler.report(error, ctx);
97
+ return this.#resolvedErrorHandler.handle(error, ctx);
98
+ };
99
+ /**
100
+ * Know if async local storage is enabled or not.
101
+ */
102
+ get usingAsyncLocalStorage() {
103
+ return asyncLocalStorage.isEnabled;
104
+ }
105
+ constructor(app, encryption, emitter, logger, config) {
106
+ this.#app = app;
107
+ this.#emitter = emitter;
108
+ this.#config = config;
109
+ this.#logger = logger;
110
+ this.#encryption = encryption;
111
+ this.#qsParser = new Qs(this.#config.qs);
112
+ this.#router = new Router(this.#app, this.#encryption, this.#qsParser);
113
+ this.#createAsyncLocalStore();
114
+ debug('server config: %O', this.#config);
115
+ }
116
+ /**
117
+ * Create async local storage store when enabled
118
+ */
119
+ #createAsyncLocalStore() {
120
+ if (this.#config.useAsyncLocalStorage) {
121
+ debug('creating ALS store for HTTP context');
122
+ asyncLocalStorage.create();
123
+ }
124
+ else {
125
+ asyncLocalStorage.destroy();
126
+ }
127
+ }
128
+ /**
129
+ * Creates an instance of the server middleware stack
130
+ */
131
+ #createServerMiddlewareStack() {
132
+ this.#serverMiddlewareStack = new Middleware();
133
+ this.#middleware.forEach((middleware) => this.#serverMiddlewareStack.add(middleware));
134
+ this.#serverMiddlewareStack.freeze();
135
+ this.#middleware = [];
136
+ }
137
+ /**
138
+ * Handles the HTTP request
139
+ */
140
+ #handleRequest(ctx, resolver) {
141
+ return this.#serverMiddlewareStack.runner()
142
+ .errorHandler((error) => this.#requestErrorResponder(error, ctx))
143
+ .finalHandler(finalHandler(this.#router, resolver, ctx, this.#requestErrorResponder))
144
+ .run(middlewareHandler(resolver, ctx))
145
+ .catch((error) => {
146
+ ctx.logger.fatal({ err: error }, 'Exception raised by error handler');
147
+ return this.#defaultErrorHandler.handle(error, ctx);
148
+ })
149
+ .finally(writeResponse(ctx));
150
+ }
151
+ /**
152
+ * Creates a pipeline of middleware.
153
+ */
154
+ pipeline(middleware) {
155
+ const middlewareStack = new Middleware();
156
+ middleware.forEach((one) => {
157
+ middlewareStack.add(moduleCaller(one, 'handle').toHandleMethod());
158
+ });
159
+ middlewareStack.freeze();
160
+ const stackRunner = middlewareStack.runner();
161
+ return {
162
+ finalHandler(handler) {
163
+ stackRunner.finalHandler(handler);
164
+ return this;
165
+ },
166
+ errorHandler(handler) {
167
+ stackRunner.errorHandler(handler);
168
+ return this;
169
+ },
170
+ run(ctx) {
171
+ return stackRunner.run((handler, next) => {
172
+ return handler.handle(ctx.containerResolver, ctx, next);
173
+ });
174
+ },
175
+ };
176
+ }
177
+ /**
178
+ * Define an array of middleware to use on all the incoming HTTP request.
179
+ * Calling this method multiple times pushes to the existing list
180
+ * of middleware
181
+ */
182
+ use(middleware) {
183
+ middleware.forEach((one) => this.#middleware.push(moduleImporter(one, 'handle').toHandleMethod()));
184
+ return this;
185
+ }
186
+ /**
187
+ * Register a custom error handler for HTTP requests.
188
+ * All errors will be reported to this method
189
+ */
190
+ errorHandler(handler) {
191
+ this.#errorHandler = handler;
192
+ return this;
193
+ }
194
+ /**
195
+ * Boot the server. Calling this method performs the following actions.
196
+ *
197
+ * - Register routes with the store.
198
+ * - Resolve and construct the error handler.
199
+ */
200
+ async boot() {
201
+ debug('booting HTTP server');
202
+ /**
203
+ * Creates the middleware stack for the server
204
+ */
205
+ this.#createServerMiddlewareStack();
206
+ /**
207
+ * Commit routes
208
+ */
209
+ this.#router.commit();
210
+ /**
211
+ * Register custom error handler
212
+ */
213
+ if (this.#errorHandler) {
214
+ if (debug.enabled) {
215
+ debug('using custom error handler "%s"', this.#errorHandler);
216
+ }
217
+ const moduleExports = await this.#errorHandler();
218
+ this.#resolvedErrorHandler = await this.#app.container.make(moduleExports.default);
219
+ }
220
+ }
221
+ /**
222
+ * Set the HTTP server instance used to listen for requests.
223
+ */
224
+ setNodeServer(server) {
225
+ this.#nodeHttpServer = server;
226
+ }
227
+ /**
228
+ * Returns reference to the underlying HTTP server
229
+ * in use
230
+ */
231
+ getNodeServer() {
232
+ return this.#nodeHttpServer;
233
+ }
234
+ /**
235
+ * Returns reference to the router instance used
236
+ * by the server.
237
+ */
238
+ getRouter() {
239
+ return this.#router;
240
+ }
241
+ /**
242
+ * Creates an instance of the [[Request]] class
243
+ */
244
+ createRequest(req, res) {
245
+ return new Request(req, res, this.#encryption, this.#config, this.#qsParser);
246
+ }
247
+ /**
248
+ * Creates an instance of the [[Response]] class
249
+ */
250
+ createResponse(req, res) {
251
+ return new Response(req, res, this.#encryption, this.#config, this.#router, this.#qsParser);
252
+ }
253
+ /**
254
+ * Creates an instance of the [[HttpContext]] class
255
+ */
256
+ createHttpContext(request, response, resolver) {
257
+ return new HttpContext(request, response, this.#logger.child({ request_id: request.id() }), resolver);
258
+ }
259
+ /**
260
+ * Handle request
261
+ */
262
+ handle(req, res) {
263
+ /**
264
+ * Setup for the "http:request_finished" event
265
+ */
266
+ const hasRequestListener = this.#emitter.hasListeners('http:request_finished');
267
+ const startTime = hasRequestListener ? process.hrtime() : null;
268
+ /**
269
+ * Creating essential instances
270
+ */
271
+ const resolver = this.#app.container.createResolver();
272
+ const ctx = this.createHttpContext(this.createRequest(req, res), this.createResponse(req, res), resolver);
273
+ /**
274
+ * Emit event when listening for the request_finished event
275
+ */
276
+ if (startTime) {
277
+ onFinished(res, () => {
278
+ this.#emitter.emit('http:request_finished', {
279
+ ctx: ctx,
280
+ duration: process.hrtime(startTime),
281
+ });
282
+ });
283
+ }
284
+ /**
285
+ * Handle request
286
+ */
287
+ if (this.usingAsyncLocalStorage) {
288
+ return asyncLocalStorage.storage.run(ctx, () => this.#handleRequest(ctx, resolver));
289
+ }
290
+ return this.#handleRequest(ctx, resolver);
291
+ }
292
+ }
@@ -0,0 +1,19 @@
1
+ export type { NextFn } from '@poppinss/middleware/types';
2
+ /**
3
+ * Accept one or more of the mentioned type
4
+ */
5
+ export type OneOrMore<T> = T | T[];
6
+ /**
7
+ * Class constructor type
8
+ */
9
+ export type Constructor<T> = new (...args: any[]) => T;
10
+ /**
11
+ * A function that lazily imports a middleware
12
+ */
13
+ export type LazyImport<DefaultExport> = () => Promise<{
14
+ default: DefaultExport;
15
+ }>;
16
+ /**
17
+ * Unwraps default export from a lazy import function
18
+ */
19
+ export type UnWrapLazyImport<Fn extends LazyImport<any>> = Awaited<ReturnType<Fn>>['default'];
@@ -0,0 +1,9 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export {};
@@ -1,14 +1,7 @@
1
- export { p as CastableHeader, C as Constructor, o as CookieOptions, E as ErrorHandlerAsAClass, r as GetControllerHandlers, G as GetMiddlewareArgs, e as HttpError, V as HttpRequestFinishedPayload, L as LazyImport, N as MakeSignedUrlOptions, K as MakeUrlOptions, s as MatchItRouteToken, A as MatchedRoute, M as MiddlewareAsClass, m as MiddlewareFn, O as OneOrMore, P as ParsedGlobalMiddleware, n as ParsedNamedMiddleware, Q as QSParserConfig, k as RequestConfig, J as ResourceActionNames, l as ResponseConfig, q as ResponseStream, t as RouteFn, I as RouteJSON, D as RouteMatcher, F as RouteMatchers, S as ServerConfig, W as ServerErrorHandler, c as StatusPageRange, d as StatusPageRenderer, y as StoreDomainNode, x as StoreMethodNode, u as StoreRouteHandler, v as StoreRouteMiddleware, w as StoreRouteNode, z as StoreRoutesTree, T as TestingMiddlewarePipeline, U as UnWrapLazyImport } from '../../main-e5b46c83.js';
2
- export { NextFn } from '@poppinss/middleware/types';
3
- import '@adonisjs/fold';
4
- import '@poppinss/macroable';
5
- import '@adonisjs/logger';
6
- import 'node:url';
7
- import '@adonisjs/encryption';
8
- import 'node:http';
9
- import 'qs';
10
- import 'http';
11
- import 'stream';
12
- import '@poppinss/middleware';
13
- import 'node:stream';
14
- import '@adonisjs/application';
1
+ export * from './base.js';
2
+ export * from './middleware.js';
3
+ export * from './qs.js';
4
+ export * from './request.js';
5
+ export * from './response.js';
6
+ export * from './route.js';
7
+ export * from './server.js';
@@ -0,0 +1,15 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export * from './base.js';
10
+ export * from './middleware.js';
11
+ export * from './qs.js';
12
+ export * from './request.js';
13
+ export * from './response.js';
14
+ export * from './route.js';
15
+ export * from './server.js';
@@ -0,0 +1,35 @@
1
+ import type { ContainerResolver } from '@adonisjs/fold';
2
+ import type { Constructor, NextFn } from './base.js';
3
+ import type { HttpContext } from '../http_context/main.js';
4
+ /**
5
+ * Middleware represented as a class
6
+ */
7
+ export type MiddlewareAsClass = Constructor<{
8
+ handle: (ctx: HttpContext, next: NextFn, args?: any) => any;
9
+ }>;
10
+ /**
11
+ * Check if a union has undefined or null
12
+ */
13
+ type HasUndefined<T> = T extends NonNullable<T> ? true : false;
14
+ /**
15
+ * Returns the arguments accepted by the middleware's handle method
16
+ */
17
+ export type GetMiddlewareArgs<Middleware extends MiddlewareAsClass> = Parameters<InstanceType<Middleware>['handle']>[2] extends undefined ? [] : HasUndefined<Parameters<InstanceType<Middleware>['handle']>[2]> extends true ? [Parameters<InstanceType<Middleware>['handle']>[2]] : [Parameters<InstanceType<Middleware>['handle']>[2]?];
18
+ /**
19
+ * The middleware defined as a function on the router or the server
20
+ */
21
+ export type MiddlewareFn = (ctx: HttpContext, next: NextFn) => any;
22
+ /**
23
+ * Parsed global middleware
24
+ */
25
+ export type ParsedGlobalMiddleware = {
26
+ handle: (resolver: ContainerResolver<any>, ...args: [ctx: HttpContext, next: NextFn, params?: any]) => any;
27
+ };
28
+ /**
29
+ * Parsed named middleware
30
+ */
31
+ export type ParsedNamedMiddleware = ParsedGlobalMiddleware & {
32
+ name: string;
33
+ args: any;
34
+ };
35
+ export {};
@@ -0,0 +1,9 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export {};
@@ -0,0 +1,68 @@
1
+ export type QSParserConfig = {
2
+ parse: {
3
+ /**
4
+ * Nesting depth till the parameters should be parsed.
5
+ *
6
+ * Defaults to 5
7
+ */
8
+ depth: number;
9
+ /**
10
+ * Number of parameters to parse.
11
+ *
12
+ * Defaults to 1000
13
+ */
14
+ parameterLimit: number;
15
+ /**
16
+ * Allow sparse elements in an array.
17
+ *
18
+ * Defaults to false
19
+ */
20
+ allowSparse: boolean;
21
+ /**
22
+ * The max limimit for the array indices. After the given limit
23
+ * the array indices will be converted to an object, where the
24
+ * index is the key.
25
+ *
26
+ * Defaults to 20
27
+ */
28
+ arrayLimit: number;
29
+ /**
30
+ * Join comma seperated query string values to an array
31
+ *
32
+ * Defaults to false
33
+ */
34
+ comma: boolean;
35
+ };
36
+ stringify: {
37
+ /**
38
+ * URI encode the stringified query string
39
+ *
40
+ * Defaults to true
41
+ */
42
+ encode: boolean;
43
+ /**
44
+ * URI encode but only the values and not the keys
45
+ *
46
+ * Defaults to false
47
+ */
48
+ encodeValuesOnly: boolean;
49
+ /**
50
+ * Define the format in which arrays should be serialized.
51
+ *
52
+ * - indices: a[0]=b&a[1]=c
53
+ * - brackets: a[]=b&a[]=c
54
+ * - repeat: a=b&a=c
55
+ * - comma: a=b,c
56
+ *
57
+ * Defaults to "indices"
58
+ */
59
+ arrayFormat: 'indices' | 'brackets' | 'repeat' | 'comma';
60
+ /**
61
+ * Whether or not to skip null values when serializing. When set to
62
+ * false, the null values will be treated as an empty string.
63
+ *
64
+ * Defaults to: false
65
+ */
66
+ skipNulls: boolean;
67
+ };
68
+ };
@@ -0,0 +1,9 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export {};
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Shape of the request config
3
+ */
4
+ export type RequestConfig = {
5
+ /**
6
+ * URL segments to ignore when extracting subdomains from a URL.
7
+ * Defaults to 2
8
+ */
9
+ subdomainOffset: number;
10
+ /**
11
+ * Enabling the flag will generated a unique request id from every
12
+ * HTTP request.
13
+ *
14
+ * The request id can be accessed using the "request.id()" method. Also,
15
+ * the value of `x-request-id` header is used as the id (if it exists).
16
+ *
17
+ * Defaults to false
18
+ */
19
+ generateRequestId: boolean;
20
+ /**
21
+ * Method spoofing allows changing the request method using the query string.
22
+ * For example: Making a POST request on URL /users/1?_method=PATCH will
23
+ * be handled by the patch route.
24
+ *
25
+ * Defaults to false
26
+ */
27
+ allowMethodSpoofing: boolean;
28
+ /**
29
+ * A custom implementation to get the request ip address
30
+ */
31
+ getIp?: (request: any) => string;
32
+ /**
33
+ * A callback function to trust proxy ip addresses. You must use
34
+ * the `proxy-addr` package to compute this value.
35
+ *
36
+ * Defaults to: "proxyAddr.compile('loopback')"
37
+ */
38
+ trustProxy: (address: string, distance: number) => boolean;
39
+ };
@@ -0,0 +1,9 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export {};
@@ -0,0 +1,45 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { Readable } from 'node:stream';
3
+ /**
4
+ * Cookie options can that can be set on the response
5
+ */
6
+ export type CookieOptions = {
7
+ domain: string;
8
+ expires: Date | (() => Date);
9
+ httpOnly: boolean;
10
+ maxAge: number | string;
11
+ path: string;
12
+ sameSite: boolean | 'lax' | 'none' | 'strict';
13
+ secure: boolean;
14
+ };
15
+ /**
16
+ * Types from which response header can be casted to a
17
+ * string
18
+ */
19
+ export type CastableHeader = string | number | boolean | string[] | number[] | boolean[];
20
+ /**
21
+ * Config accepted by response the class
22
+ */
23
+ export type ResponseConfig = {
24
+ /**
25
+ * Whether or not to generate etags for responses. Etags can be
26
+ * enabled/disabled when sending response as well.
27
+ *
28
+ * Defaults to false
29
+ */
30
+ etag: boolean;
31
+ /**
32
+ * The callback name for the JSONP response.
33
+ *
34
+ * Defaults to 'callback'
35
+ */
36
+ jsonpCallbackName: string;
37
+ /**
38
+ * Options to set cookies
39
+ */
40
+ cookie: Partial<CookieOptions>;
41
+ };
42
+ /**
43
+ * Stream that can be piped to the "response.stream" method
44
+ */
45
+ export type ResponseStream = Readable;
@@ -0,0 +1,9 @@
1
+ /*
2
+ * @adonisjs/http-server
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ export {};