@adonisjs/http-server 6.8.2-3 → 6.8.2-5

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 (159) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/factories/http_context.d.ts +1 -0
  3. package/build/factories/http_context.d.ts.map +1 -0
  4. package/build/factories/main.d.ts +1 -0
  5. package/build/factories/main.d.ts.map +1 -0
  6. package/build/factories/qs_parser_factory.d.ts +1 -0
  7. package/build/factories/qs_parser_factory.d.ts.map +1 -0
  8. package/build/factories/request.d.ts +1 -0
  9. package/build/factories/request.d.ts.map +1 -0
  10. package/build/factories/response.d.ts +1 -0
  11. package/build/factories/response.d.ts.map +1 -0
  12. package/build/factories/router.d.ts +1 -0
  13. package/build/factories/router.d.ts.map +1 -0
  14. package/build/factories/server_factory.d.ts +1 -0
  15. package/build/factories/server_factory.d.ts.map +1 -0
  16. package/build/index.d.ts +1 -0
  17. package/build/index.d.ts.map +1 -0
  18. package/build/src/cookies/client.d.ts +1 -0
  19. package/build/src/cookies/client.d.ts.map +1 -0
  20. package/build/src/cookies/drivers/encrypted.d.ts +1 -0
  21. package/build/src/cookies/drivers/encrypted.d.ts.map +1 -0
  22. package/build/src/cookies/drivers/plain.d.ts +1 -0
  23. package/build/src/cookies/drivers/plain.d.ts.map +1 -0
  24. package/build/src/cookies/drivers/signed.d.ts +1 -0
  25. package/build/src/cookies/drivers/signed.d.ts.map +1 -0
  26. package/build/src/cookies/parser.d.ts +1 -0
  27. package/build/src/cookies/parser.d.ts.map +1 -0
  28. package/build/src/cookies/serializer.d.ts +1 -0
  29. package/build/src/cookies/serializer.d.ts.map +1 -0
  30. package/build/src/debug.d.ts +1 -0
  31. package/build/src/debug.d.ts.map +1 -0
  32. package/build/src/define_config.d.ts +1 -0
  33. package/build/src/define_config.d.ts.map +1 -0
  34. package/build/src/define_middleware.d.ts +1 -0
  35. package/build/src/define_middleware.d.ts.map +1 -0
  36. package/build/src/exception_handler.d.ts +1 -0
  37. package/build/src/exception_handler.d.ts.map +1 -0
  38. package/build/src/exceptions.d.ts +1 -0
  39. package/build/src/exceptions.d.ts.map +1 -0
  40. package/build/src/helpers.d.ts +1 -0
  41. package/build/src/helpers.d.ts.map +1 -0
  42. package/build/src/http_context/local_storage.d.ts +1 -0
  43. package/build/src/http_context/local_storage.d.ts.map +1 -0
  44. package/build/src/http_context/main.d.ts +1 -0
  45. package/build/src/http_context/main.d.ts.map +1 -0
  46. package/build/src/qs.d.ts +1 -0
  47. package/build/src/qs.d.ts.map +1 -0
  48. package/build/src/redirect.d.ts +1 -0
  49. package/build/src/redirect.d.ts.map +1 -0
  50. package/build/src/request.d.ts +1 -0
  51. package/build/src/request.d.ts.map +1 -0
  52. package/build/src/response.d.ts +1 -0
  53. package/build/src/response.d.ts.map +1 -0
  54. package/build/src/router/brisk.d.ts +1 -0
  55. package/build/src/router/brisk.d.ts.map +1 -0
  56. package/build/src/router/executor.d.ts +1 -0
  57. package/build/src/router/executor.d.ts.map +1 -0
  58. package/build/src/router/factories/use_return_value.d.ts +1 -0
  59. package/build/src/router/factories/use_return_value.d.ts.map +1 -0
  60. package/build/src/router/group.d.ts +1 -0
  61. package/build/src/router/group.d.ts.map +1 -0
  62. package/build/src/router/lookup_store/main.d.ts +1 -0
  63. package/build/src/router/lookup_store/main.d.ts.map +1 -0
  64. package/build/src/router/lookup_store/route_finder.d.ts +1 -0
  65. package/build/src/router/lookup_store/route_finder.d.ts.map +1 -0
  66. package/build/src/router/lookup_store/url_builder.d.ts +1 -0
  67. package/build/src/router/lookup_store/url_builder.d.ts.map +1 -0
  68. package/build/src/router/lookup_store/url_builder.js +2 -2
  69. package/build/src/router/main.d.ts +4 -2
  70. package/build/src/router/main.d.ts.map +1 -0
  71. package/build/src/router/main.js +4 -0
  72. package/build/src/router/matchers.d.ts +1 -0
  73. package/build/src/router/matchers.d.ts.map +1 -0
  74. package/build/src/router/parser.d.ts +3 -0
  75. package/build/src/router/parser.d.ts.map +1 -0
  76. package/build/src/router/parser.js +5 -0
  77. package/build/src/router/resource.d.ts +1 -0
  78. package/build/src/router/resource.d.ts.map +1 -0
  79. package/build/src/router/route.d.ts +1 -0
  80. package/build/src/router/route.d.ts.map +1 -0
  81. package/build/src/router/store.d.ts +1 -0
  82. package/build/src/router/store.d.ts.map +1 -0
  83. package/build/src/router/store.js +3 -2
  84. package/build/src/server/factories/final_handler.d.ts +1 -0
  85. package/build/src/server/factories/final_handler.d.ts.map +1 -0
  86. package/build/src/server/factories/middleware_handler.d.ts +1 -0
  87. package/build/src/server/factories/middleware_handler.d.ts.map +1 -0
  88. package/build/src/server/factories/write_response.d.ts +1 -0
  89. package/build/src/server/factories/write_response.d.ts.map +1 -0
  90. package/build/src/server/main.d.ts +1 -0
  91. package/build/src/server/main.d.ts.map +1 -0
  92. package/build/src/types/base.d.ts +1 -0
  93. package/build/src/types/base.d.ts.map +1 -0
  94. package/build/src/types/main.d.ts +1 -0
  95. package/build/src/types/main.d.ts.map +1 -0
  96. package/build/src/types/middleware.d.ts +1 -0
  97. package/build/src/types/middleware.d.ts.map +1 -0
  98. package/build/src/types/qs.d.ts +1 -0
  99. package/build/src/types/qs.d.ts.map +1 -0
  100. package/build/src/types/request.d.ts +1 -0
  101. package/build/src/types/request.d.ts.map +1 -0
  102. package/build/src/types/response.d.ts +1 -0
  103. package/build/src/types/response.d.ts.map +1 -0
  104. package/build/src/types/route.d.ts +1 -0
  105. package/build/src/types/route.d.ts.map +1 -0
  106. package/build/src/types/server.d.ts +1 -0
  107. package/build/src/types/server.d.ts.map +1 -0
  108. package/factories/http_context.ts +73 -0
  109. package/factories/main.ts +15 -0
  110. package/factories/qs_parser_factory.ts +54 -0
  111. package/factories/request.ts +101 -0
  112. package/factories/response.ts +106 -0
  113. package/factories/router.ts +61 -0
  114. package/factories/server_factory.ts +94 -0
  115. package/index.ts +23 -0
  116. package/package.json +27 -23
  117. package/src/cookies/client.ts +98 -0
  118. package/src/cookies/drivers/encrypted.ts +42 -0
  119. package/src/cookies/drivers/plain.ts +37 -0
  120. package/src/cookies/drivers/signed.ts +42 -0
  121. package/src/cookies/parser.ts +196 -0
  122. package/src/cookies/serializer.ts +98 -0
  123. package/src/debug.ts +11 -0
  124. package/src/define_config.ts +56 -0
  125. package/src/define_middleware.ts +61 -0
  126. package/src/exception_handler.ts +290 -0
  127. package/src/exceptions.ts +55 -0
  128. package/src/helpers.ts +108 -0
  129. package/src/http_context/local_storage.ts +50 -0
  130. package/src/http_context/main.ts +126 -0
  131. package/src/qs.ts +31 -0
  132. package/src/redirect.ts +181 -0
  133. package/src/request.ts +982 -0
  134. package/src/response.ts +1421 -0
  135. package/src/router/brisk.ts +113 -0
  136. package/src/router/executor.ts +36 -0
  137. package/src/router/factories/use_return_value.ts +26 -0
  138. package/src/router/group.ts +243 -0
  139. package/src/router/lookup_store/main.ts +102 -0
  140. package/src/router/lookup_store/route_finder.ts +60 -0
  141. package/src/router/lookup_store/url_builder.ts +250 -0
  142. package/src/router/main.ts +431 -0
  143. package/src/router/matchers.ts +40 -0
  144. package/src/router/parser.ts +20 -0
  145. package/src/router/resource.ts +277 -0
  146. package/src/router/route.ts +363 -0
  147. package/src/router/store.ts +239 -0
  148. package/src/server/factories/final_handler.ts +38 -0
  149. package/src/server/factories/middleware_handler.ts +23 -0
  150. package/src/server/factories/write_response.ts +26 -0
  151. package/src/server/main.ts +356 -0
  152. package/src/types/base.ts +30 -0
  153. package/src/types/main.ts +16 -0
  154. package/src/types/middleware.ts +59 -0
  155. package/src/types/qs.ts +85 -0
  156. package/src/types/request.ts +52 -0
  157. package/src/types/response.ts +57 -0
  158. package/src/types/route.ts +217 -0
  159. package/src/types/server.ts +92 -0
@@ -0,0 +1,16 @@
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
+
10
+ export * from './base.js'
11
+ export * from './middleware.js'
12
+ export * from './qs.js'
13
+ export * from './request.js'
14
+ export * from './response.js'
15
+ export * from './route.js'
16
+ export * from './server.js'
@@ -0,0 +1,59 @@
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
+
10
+ import type { ContainerResolver } from '@adonisjs/fold'
11
+
12
+ import type { Constructor, NextFn } from './base.js'
13
+ import type { HttpContext } from '../http_context/main.js'
14
+
15
+ /**
16
+ * Middleware represented as a class
17
+ */
18
+ export type MiddlewareAsClass = Constructor<{
19
+ handle: (ctx: HttpContext, next: NextFn, args?: any) => any
20
+ }>
21
+
22
+ /**
23
+ * Check if a union has undefined or null
24
+ */
25
+ type HasUndefined<T> = T extends NonNullable<T> ? true : false
26
+
27
+ /**
28
+ * Returns the arguments accepted by the middleware's handle method
29
+ */
30
+ export type GetMiddlewareArgs<Middleware extends MiddlewareAsClass> = Parameters<
31
+ InstanceType<Middleware>['handle']
32
+ >[2] extends undefined
33
+ ? []
34
+ : HasUndefined<Parameters<InstanceType<Middleware>['handle']>[2]> extends true
35
+ ? [Parameters<InstanceType<Middleware>['handle']>[2]]
36
+ : [Parameters<InstanceType<Middleware>['handle']>[2]?]
37
+
38
+ /**
39
+ * The middleware defined as a function on the router or the server
40
+ */
41
+ export type MiddlewareFn = (ctx: HttpContext, next: NextFn) => any
42
+
43
+ /**
44
+ * Parsed global middleware
45
+ */
46
+ export type ParsedGlobalMiddleware = {
47
+ handle: (
48
+ resolver: ContainerResolver<any>,
49
+ ...args: [ctx: HttpContext, next: NextFn, params?: any]
50
+ ) => any
51
+ }
52
+
53
+ /**
54
+ * Parsed named middleware
55
+ */
56
+ export type ParsedNamedMiddleware = ParsedGlobalMiddleware & {
57
+ name: string
58
+ args: any
59
+ }
@@ -0,0 +1,85 @@
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
+
10
+ export type QSParserConfig = {
11
+ parse: {
12
+ /**
13
+ * Nesting depth till the parameters should be parsed.
14
+ *
15
+ * Defaults to 5
16
+ */
17
+ depth: number
18
+
19
+ /**
20
+ * Number of parameters to parse.
21
+ *
22
+ * Defaults to 1000
23
+ */
24
+ parameterLimit: number
25
+
26
+ /**
27
+ * Allow sparse elements in an array.
28
+ *
29
+ * Defaults to false
30
+ */
31
+ allowSparse: boolean
32
+
33
+ /**
34
+ * The max limimit for the array indices. After the given limit
35
+ * the array indices will be converted to an object, where the
36
+ * index is the key.
37
+ *
38
+ * Defaults to 20
39
+ */
40
+ arrayLimit: number
41
+
42
+ /**
43
+ * Join comma seperated query string values to an array
44
+ *
45
+ * Defaults to false
46
+ */
47
+ comma: boolean
48
+ }
49
+
50
+ stringify: {
51
+ /**
52
+ * URI encode the stringified query string
53
+ *
54
+ * Defaults to true
55
+ */
56
+ encode: boolean
57
+
58
+ /**
59
+ * URI encode but only the values and not the keys
60
+ *
61
+ * Defaults to false
62
+ */
63
+ encodeValuesOnly: boolean
64
+
65
+ /**
66
+ * Define the format in which arrays should be serialized.
67
+ *
68
+ * - indices: a[0]=b&a[1]=c
69
+ * - brackets: a[]=b&a[]=c
70
+ * - repeat: a=b&a=c
71
+ * - comma: a=b,c
72
+ *
73
+ * Defaults to "indices"
74
+ */
75
+ arrayFormat: 'indices' | 'brackets' | 'repeat' | 'comma'
76
+
77
+ /**
78
+ * Whether or not to skip null values when serializing. When set to
79
+ * false, the null values will be treated as an empty string.
80
+ *
81
+ * Defaults to: false
82
+ */
83
+ skipNulls: boolean
84
+ }
85
+ }
@@ -0,0 +1,52 @@
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
+
10
+ /**
11
+ * Shape of the request config
12
+ */
13
+ export type RequestConfig = {
14
+ /**
15
+ * URL segments to ignore when extracting subdomains from a URL.
16
+ * Defaults to 2
17
+ */
18
+ subdomainOffset: number
19
+
20
+ /**
21
+ * Enabling the flag will generated a unique request id from every
22
+ * HTTP request.
23
+ *
24
+ * The request id can be accessed using the "request.id()" method. Also,
25
+ * the value of `x-request-id` header is used as the id (if it exists).
26
+ *
27
+ * Defaults to false
28
+ */
29
+ generateRequestId: boolean
30
+
31
+ /**
32
+ * Method spoofing allows changing the request method using the query string.
33
+ * For example: Making a POST request on URL /users/1?_method=PATCH will
34
+ * be handled by the patch route.
35
+ *
36
+ * Defaults to false
37
+ */
38
+ allowMethodSpoofing: boolean
39
+
40
+ /**
41
+ * A custom implementation to get the request ip address
42
+ */
43
+ getIp?: (request: any) => string
44
+
45
+ /**
46
+ * A callback function to trust proxy ip addresses. You must use
47
+ * the `proxy-addr` package to compute this value.
48
+ *
49
+ * Defaults to: "proxyAddr.compile('loopback')"
50
+ */
51
+ trustProxy: (address: string, distance: number) => boolean
52
+ }
@@ -0,0 +1,57 @@
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
+
10
+ /**
11
+ * Cookie options can that can be set on the response
12
+ */
13
+ export type CookieOptions = {
14
+ domain: string
15
+ expires: Date | (() => Date)
16
+ httpOnly: boolean
17
+ maxAge: number | string
18
+ path: string
19
+ sameSite: boolean | 'lax' | 'none' | 'strict'
20
+ secure: boolean
21
+ }
22
+
23
+ /**
24
+ * Types from which response header can be casted to a
25
+ * string
26
+ */
27
+ export type CastableHeader = string | number | boolean | string[] | number[] | boolean[]
28
+
29
+ /**
30
+ * Config accepted by response the class
31
+ */
32
+ export type ResponseConfig = {
33
+ /**
34
+ * Whether or not to generate etags for responses. Etags can be
35
+ * enabled/disabled when sending response as well.
36
+ *
37
+ * Defaults to false
38
+ */
39
+ etag: boolean
40
+
41
+ /**
42
+ * The callback name for the JSONP response.
43
+ *
44
+ * Defaults to 'callback'
45
+ */
46
+ jsonpCallbackName: string
47
+
48
+ /**
49
+ * Options to set cookies
50
+ */
51
+ cookie: Partial<CookieOptions>
52
+ }
53
+
54
+ /**
55
+ * Stream that can be piped to the "response.stream" method
56
+ */
57
+ export type ResponseStream = NodeJS.ReadStream | NodeJS.ReadWriteStream | NodeJS.ReadableStream
@@ -0,0 +1,217 @@
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
+
10
+ import type Middleware from '@poppinss/middleware'
11
+ import type { ContainerResolver } from '@adonisjs/fold'
12
+
13
+ import type { Constructor, LazyImport } from './base.js'
14
+ import type { HttpContext } from '../http_context/main.js'
15
+ import type { MiddlewareFn, ParsedGlobalMiddleware } from './middleware.js'
16
+
17
+ /**
18
+ * Returns a union of methods from a controller that accepts
19
+ * the context as the first argument.
20
+ */
21
+ export type GetControllerHandlers<Controller extends Constructor<any>> = {
22
+ [K in keyof InstanceType<Controller>]: InstanceType<Controller>[K] extends (
23
+ ctx: HttpContext,
24
+ ...args: any[]
25
+ ) => any
26
+ ? K
27
+ : never
28
+ }[keyof InstanceType<Controller>]
29
+
30
+ /**
31
+ * Route token stored by matchit library
32
+ */
33
+ export type MatchItRouteToken = RouteMatcher & {
34
+ old: string
35
+ type: 0 | 1 | 2 | 3
36
+ val: string
37
+ end: string
38
+ }
39
+
40
+ /**
41
+ * Route handler defined as a function
42
+ */
43
+ export type RouteFn = (ctx: HttpContext) => any
44
+
45
+ /**
46
+ * Route handler persisted with the route store
47
+ */
48
+ export type StoreRouteHandler =
49
+ | RouteFn
50
+ | {
51
+ reference: string | [LazyImport<Constructor<any>> | Constructor<any>, any?]
52
+ handle: (
53
+ resolver: ContainerResolver<any>,
54
+ ...args: [ctx: HttpContext, ...injections: any[]]
55
+ ) => any
56
+ }
57
+
58
+ /**
59
+ * The middleware persisted with the route store
60
+ */
61
+ export type StoreRouteMiddleware =
62
+ | MiddlewareFn
63
+ | ({ name?: string; args?: any[] } & ParsedGlobalMiddleware)
64
+
65
+ /**
66
+ * Route node persisted within the routes store
67
+ */
68
+ export type StoreRouteNode = {
69
+ /**
70
+ * The execute function to execute the route middleware
71
+ * and the handler
72
+ */
73
+ execute: (route: StoreRouteNode, resolver: ContainerResolver<any>, ctx: HttpContext) => any
74
+
75
+ /**
76
+ * A unique name for the route
77
+ */
78
+ name?: string
79
+
80
+ /**
81
+ * Route URI pattern
82
+ */
83
+ pattern: string
84
+
85
+ /**
86
+ * Route handler
87
+ */
88
+ handler: StoreRouteHandler
89
+
90
+ /**
91
+ * Route middleware
92
+ */
93
+ middleware: Middleware<StoreRouteMiddleware>
94
+
95
+ /**
96
+ * Additional metadata associated with the route
97
+ */
98
+ meta: Record<string, any>
99
+ }
100
+
101
+ /**
102
+ * An object of routes for a given HTTP method
103
+ */
104
+ export type StoreMethodNode = {
105
+ tokens: MatchItRouteToken[][]
106
+ routeKeys: {
107
+ [pattern: string]: string
108
+ }
109
+ routes: {
110
+ [pattern: string]: StoreRouteNode
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Each domain node container an object of methods. Each method
116
+ * object has nested routes.
117
+ */
118
+ export type StoreDomainNode = {
119
+ [method: string]: StoreMethodNode
120
+ }
121
+
122
+ /**
123
+ * Routes tree stored within the routes store
124
+ */
125
+ export type StoreRoutesTree = {
126
+ tokens: MatchItRouteToken[][]
127
+ domains: {
128
+ [domain: string]: StoreDomainNode
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Shape of the matched route for a pattern, method and domain.
134
+ */
135
+ export type MatchedRoute = {
136
+ route: StoreRouteNode
137
+
138
+ /**
139
+ * A unique key for the looked up route
140
+ */
141
+ routeKey: string
142
+
143
+ /**
144
+ * Route params
145
+ */
146
+ params: Record<string, any>
147
+
148
+ /**
149
+ * Route subdomains (if part of a subdomain)
150
+ */
151
+ subdomains: Record<string, any>
152
+ }
153
+
154
+ /**
155
+ * Shape of a route param matcher
156
+ */
157
+ export type RouteMatcher = {
158
+ match?: RegExp
159
+ cast?: (value: string) => any
160
+ }
161
+
162
+ /**
163
+ * A collection of route matchers
164
+ */
165
+ export type RouteMatchers = {
166
+ [param: string]: RouteMatcher
167
+ }
168
+
169
+ /**
170
+ * Representation of a route as JSON
171
+ */
172
+ export type RouteJSON = StoreRouteNode & {
173
+ /**
174
+ * HTTP methods, the route responds to.
175
+ */
176
+ methods: string[]
177
+
178
+ /**
179
+ * The domain for which the route is registered.
180
+ */
181
+ domain: string
182
+
183
+ /**
184
+ * Matchers for route params.
185
+ */
186
+ matchers: RouteMatchers
187
+ }
188
+
189
+ /**
190
+ * Resource action names
191
+ */
192
+ export type ResourceActionNames =
193
+ | 'create'
194
+ | 'index'
195
+ | 'store'
196
+ | 'show'
197
+ | 'edit'
198
+ | 'update'
199
+ | 'destroy'
200
+
201
+ /**
202
+ * Options accepted by makeUrl method
203
+ */
204
+ export type MakeUrlOptions = {
205
+ qs?: Record<string, any>
206
+ domain?: string
207
+ prefixUrl?: string
208
+ disableRouteLookup?: boolean
209
+ }
210
+
211
+ /**
212
+ * Options accepted by makeSignedUrl method
213
+ */
214
+ export type MakeSignedUrlOptions = MakeUrlOptions & {
215
+ expiresIn?: string | number
216
+ purpose?: string
217
+ }
@@ -0,0 +1,92 @@
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
+
10
+ import type { ErrorHandler, FinalHandler } from '@poppinss/middleware/types'
11
+
12
+ import type { Constructor } from './base.js'
13
+ import type { QSParserConfig } from './qs.js'
14
+ import type { RequestConfig } from './request.js'
15
+ import type { ResponseConfig } from './response.js'
16
+ import type { HttpContext } from '../http_context/main.js'
17
+
18
+ /**
19
+ * Normalized HTTP error used by the exception
20
+ * handler.
21
+ */
22
+ export type HttpError = {
23
+ message: string
24
+ status: number
25
+ code?: string
26
+ stack?: string
27
+ cause?: any
28
+ messages?: any
29
+ errors?: any
30
+ handle?: (...args: any[]) => any
31
+ report?: (...args: any[]) => any
32
+ }
33
+
34
+ /**
35
+ * The pipeline for executing middleware during tests
36
+ */
37
+ export interface TestingMiddlewarePipeline {
38
+ finalHandler(handler: FinalHandler): this
39
+ errorHandler(handler: ErrorHandler): this
40
+ run(ctx: HttpContext): Promise<any>
41
+ }
42
+
43
+ /**
44
+ * The expression to define a status page range
45
+ */
46
+ export type StatusPageRange = `${number}..${number}`
47
+
48
+ /**
49
+ * The callback function to render status page for a given
50
+ * error.
51
+ */
52
+ export type StatusPageRenderer = (error: HttpError, ctx: HttpContext) => any | Promise<any>
53
+
54
+ /**
55
+ * Data type for the "http:request_finished" event
56
+ */
57
+ export type HttpRequestFinishedPayload = {
58
+ ctx: HttpContext
59
+ duration: [number, number]
60
+ }
61
+
62
+ /**
63
+ * Error handler to handle HTTP errors
64
+ */
65
+ export type ServerErrorHandler = {
66
+ report: (error: any, ctx: HttpContext) => any
67
+ handle: (error: any, ctx: HttpContext) => any
68
+ }
69
+
70
+ /**
71
+ * Error handler represented as a class
72
+ */
73
+ export type ErrorHandlerAsAClass = Constructor<ServerErrorHandler>
74
+
75
+ /**
76
+ * Config accepted by the HTTP server
77
+ */
78
+ export type ServerConfig = RequestConfig &
79
+ ResponseConfig & {
80
+ /**
81
+ * Whether or not to create an async local storage store for
82
+ * the HTTP context.
83
+ *
84
+ * Defaults to false
85
+ */
86
+ useAsyncLocalStorage: boolean
87
+
88
+ /**
89
+ * Config for query string parser
90
+ */
91
+ qs: QSParserConfig
92
+ }