@adonisjs/http-server 6.8.2-5 → 6.8.2-7
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 +3 -6
- package/build/factories/http_context.d.ts +10 -1
- package/build/factories/http_context.js +27 -0
- package/build/factories/http_server.d.ts +8 -0
- package/build/factories/http_server.js +26 -0
- package/build/factories/main.d.ts +0 -1
- package/build/factories/main.js +8 -0
- package/build/factories/qs_parser_factory.d.ts +10 -1
- package/build/factories/qs_parser_factory.js +18 -0
- package/build/factories/request.d.ts +10 -1
- package/build/factories/request.js +31 -0
- package/build/factories/response.d.ts +10 -1
- package/build/factories/response.js +34 -0
- package/build/factories/router.d.ts +10 -1
- package/build/factories/router.js +25 -0
- package/build/factories/server_factory.d.ts +10 -1
- package/build/factories/server_factory.js +34 -0
- package/build/index.d.ts +0 -1
- package/build/index.js +8 -0
- package/build/src/cookies/client.d.ts +25 -1
- package/build/src/cookies/client.js +42 -0
- package/build/src/cookies/drivers/encrypted.d.ts +12 -1
- package/build/src/cookies/drivers/encrypted.js +20 -0
- package/build/src/cookies/drivers/plain.d.ts +12 -1
- package/build/src/cookies/drivers/plain.js +20 -0
- package/build/src/cookies/drivers/signed.d.ts +12 -1
- package/build/src/cookies/drivers/signed.js +20 -0
- package/build/src/cookies/parser.d.ts +28 -1
- package/build/src/cookies/parser.js +98 -0
- package/build/src/cookies/serializer.d.ts +22 -1
- package/build/src/cookies/serializer.js +40 -0
- package/build/src/debug.d.ts +0 -1
- package/build/src/debug.js +8 -0
- package/build/src/define_config.d.ts +3 -1
- package/build/src/define_config.js +11 -0
- package/build/src/define_middleware.d.ts +5 -1
- package/build/src/define_middleware.js +18 -0
- package/build/src/exception_handler.d.ts +65 -1
- package/build/src/exception_handler.js +95 -0
- package/build/src/exceptions.d.ts +6 -1
- package/build/src/exceptions.js +11 -0
- package/build/src/helpers.d.ts +14 -1
- package/build/src/helpers.js +22 -0
- package/build/src/http_context/local_storage.d.ts +3 -1
- package/build/src/http_context/local_storage.js +25 -0
- package/build/src/http_context/main.d.ts +36 -1
- package/build/src/http_context/main.js +54 -0
- package/build/src/qs.d.ts +4 -1
- package/build/src/qs.js +12 -0
- package/build/src/redirect.d.ts +24 -1
- package/build/src/redirect.js +60 -0
- package/build/src/request.d.ts +466 -1
- package/build/src/request.js +542 -0
- package/build/src/response.d.ts +425 -2
- package/build/src/response.js +608 -7
- package/build/src/router/brisk.d.ts +22 -1
- package/build/src/router/brisk.js +42 -0
- package/build/src/router/executor.d.ts +4 -1
- package/build/src/router/executor.js +12 -0
- package/build/src/router/factories/use_return_value.d.ts +4 -1
- package/build/src/router/factories/use_return_value.js +16 -3
- package/build/src/router/group.d.ts +47 -1
- package/build/src/router/group.js +88 -0
- package/build/src/router/lookup_store/main.d.ts +32 -1
- package/build/src/router/lookup_store/main.js +49 -0
- package/build/src/router/lookup_store/route_finder.d.ts +13 -1
- package/build/src/router/lookup_store/route_finder.js +21 -0
- package/build/src/router/lookup_store/url_builder.d.ts +36 -1
- package/build/src/router/lookup_store/url_builder.js +97 -0
- package/build/src/router/main.d.ts +87 -1
- package/build/src/router/main.js +142 -0
- package/build/src/router/matchers.d.ts +13 -1
- package/build/src/router/matchers.js +21 -0
- package/build/src/router/parser.d.ts +3 -1
- package/build/src/router/parser.js +12 -0
- package/build/src/router/resource.d.ts +28 -1
- package/build/src/router/resource.js +90 -0
- package/build/src/router/route.d.ts +65 -1
- package/build/src/router/route.js +142 -0
- package/build/src/router/store.d.ts +54 -1
- package/build/src/router/store.js +102 -0
- package/build/src/server/factories/final_handler.d.ts +5 -1
- package/build/src/server/factories/final_handler.js +13 -0
- package/build/src/server/factories/middleware_handler.d.ts +3 -1
- package/build/src/server/factories/middleware_handler.js +11 -0
- package/build/src/server/factories/write_response.d.ts +4 -1
- package/build/src/server/factories/write_response.js +12 -0
- package/build/src/server/main.d.ts +48 -1
- package/build/src/server/main.js +128 -0
- package/build/src/types/base.d.ts +12 -1
- package/build/src/types/base.js +8 -0
- package/build/src/types/main.d.ts +0 -1
- package/build/src/types/main.js +8 -0
- package/build/src/types/middleware.d.ts +18 -1
- package/build/src/types/middleware.js +8 -0
- package/build/src/types/qs.d.ts +53 -1
- package/build/src/types/qs.js +8 -0
- package/build/src/types/request.d.ts +32 -1
- package/build/src/types/request.js +8 -0
- package/build/src/types/response.d.ts +27 -1
- package/build/src/types/response.js +8 -0
- package/build/src/types/route.d.ts +87 -1
- package/build/src/types/route.js +8 -0
- package/build/src/types/server.d.ts +35 -1
- package/build/src/types/server.js +8 -0
- package/package.json +43 -70
- package/build/factories/http_context.d.ts.map +0 -1
- package/build/factories/main.d.ts.map +0 -1
- package/build/factories/qs_parser_factory.d.ts.map +0 -1
- package/build/factories/request.d.ts.map +0 -1
- package/build/factories/response.d.ts.map +0 -1
- package/build/factories/router.d.ts.map +0 -1
- package/build/factories/server_factory.d.ts.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/src/cookies/client.d.ts.map +0 -1
- package/build/src/cookies/drivers/encrypted.d.ts.map +0 -1
- package/build/src/cookies/drivers/plain.d.ts.map +0 -1
- package/build/src/cookies/drivers/signed.d.ts.map +0 -1
- package/build/src/cookies/parser.d.ts.map +0 -1
- package/build/src/cookies/serializer.d.ts.map +0 -1
- package/build/src/debug.d.ts.map +0 -1
- package/build/src/define_config.d.ts.map +0 -1
- package/build/src/define_middleware.d.ts.map +0 -1
- package/build/src/exception_handler.d.ts.map +0 -1
- package/build/src/exceptions.d.ts.map +0 -1
- package/build/src/helpers.d.ts.map +0 -1
- package/build/src/http_context/local_storage.d.ts.map +0 -1
- package/build/src/http_context/main.d.ts.map +0 -1
- package/build/src/qs.d.ts.map +0 -1
- package/build/src/redirect.d.ts.map +0 -1
- package/build/src/request.d.ts.map +0 -1
- package/build/src/response.d.ts.map +0 -1
- package/build/src/router/brisk.d.ts.map +0 -1
- package/build/src/router/executor.d.ts.map +0 -1
- package/build/src/router/factories/use_return_value.d.ts.map +0 -1
- package/build/src/router/group.d.ts.map +0 -1
- package/build/src/router/lookup_store/main.d.ts.map +0 -1
- package/build/src/router/lookup_store/route_finder.d.ts.map +0 -1
- package/build/src/router/lookup_store/url_builder.d.ts.map +0 -1
- package/build/src/router/main.d.ts.map +0 -1
- package/build/src/router/matchers.d.ts.map +0 -1
- package/build/src/router/parser.d.ts.map +0 -1
- package/build/src/router/resource.d.ts.map +0 -1
- package/build/src/router/route.d.ts.map +0 -1
- package/build/src/router/store.d.ts.map +0 -1
- package/build/src/server/factories/final_handler.d.ts.map +0 -1
- package/build/src/server/factories/middleware_handler.d.ts.map +0 -1
- package/build/src/server/factories/write_response.d.ts.map +0 -1
- package/build/src/server/main.d.ts.map +0 -1
- package/build/src/types/base.d.ts.map +0 -1
- package/build/src/types/main.d.ts.map +0 -1
- package/build/src/types/middleware.d.ts.map +0 -1
- package/build/src/types/qs.d.ts.map +0 -1
- package/build/src/types/request.d.ts.map +0 -1
- package/build/src/types/response.d.ts.map +0 -1
- package/build/src/types/route.d.ts.map +0 -1
- package/build/src/types/server.d.ts.map +0 -1
- package/factories/http_context.ts +0 -73
- package/factories/main.ts +0 -15
- package/factories/qs_parser_factory.ts +0 -54
- package/factories/request.ts +0 -101
- package/factories/response.ts +0 -106
- package/factories/router.ts +0 -61
- package/factories/server_factory.ts +0 -94
- package/index.ts +0 -23
- package/src/cookies/client.ts +0 -98
- package/src/cookies/drivers/encrypted.ts +0 -42
- package/src/cookies/drivers/plain.ts +0 -37
- package/src/cookies/drivers/signed.ts +0 -42
- package/src/cookies/parser.ts +0 -196
- package/src/cookies/serializer.ts +0 -98
- package/src/debug.ts +0 -11
- package/src/define_config.ts +0 -56
- package/src/define_middleware.ts +0 -61
- package/src/exception_handler.ts +0 -290
- package/src/exceptions.ts +0 -55
- package/src/helpers.ts +0 -108
- package/src/http_context/local_storage.ts +0 -50
- package/src/http_context/main.ts +0 -126
- package/src/qs.ts +0 -31
- package/src/redirect.ts +0 -181
- package/src/request.ts +0 -982
- package/src/response.ts +0 -1421
- package/src/router/brisk.ts +0 -113
- package/src/router/executor.ts +0 -36
- package/src/router/factories/use_return_value.ts +0 -26
- package/src/router/group.ts +0 -243
- package/src/router/lookup_store/main.ts +0 -102
- package/src/router/lookup_store/route_finder.ts +0 -60
- package/src/router/lookup_store/url_builder.ts +0 -250
- package/src/router/main.ts +0 -431
- package/src/router/matchers.ts +0 -40
- package/src/router/parser.ts +0 -20
- package/src/router/resource.ts +0 -277
- package/src/router/route.ts +0 -363
- package/src/router/store.ts +0 -239
- package/src/server/factories/final_handler.ts +0 -38
- package/src/server/factories/middleware_handler.ts +0 -23
- package/src/server/factories/write_response.ts +0 -26
- package/src/server/main.ts +0 -356
- package/src/types/base.ts +0 -30
- package/src/types/main.ts +0 -16
- package/src/types/middleware.ts +0 -59
- package/src/types/qs.ts +0 -85
- package/src/types/request.ts +0 -52
- package/src/types/response.ts +0 -57
- package/src/types/route.ts +0 -217
- package/src/types/server.ts +0 -92
package/src/types/main.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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'
|
package/src/types/middleware.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
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
|
-
}
|
package/src/types/qs.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
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
|
-
}
|
package/src/types/request.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
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
|
-
}
|
package/src/types/response.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
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
|
package/src/types/route.ts
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
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
|
-
}
|
package/src/types/server.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
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
|
-
}
|