@adonisjs/http-server 8.0.0-next.4 → 8.0.0-next.6
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-BFGF3A5X.js → chunk-7ROFCP6L.js} +1095 -548
- package/build/{chunk-ASX56VAK.js → chunk-NQNHMINZ.js} +59 -0
- package/build/factories/http_context.d.ts +2 -1
- package/build/factories/http_server.d.ts +7 -0
- package/build/factories/main.js +31 -5
- package/build/factories/qs_parser_factory.d.ts +3 -2
- package/build/factories/request.d.ts +1 -0
- package/build/factories/response.d.ts +1 -0
- package/build/factories/router.d.ts +1 -0
- package/build/factories/server_factory.d.ts +1 -0
- package/build/factories/url_builder_factory.d.ts +1 -0
- package/build/index.d.ts +3 -1
- package/build/index.js +87 -37
- package/build/src/cookies/client.d.ts +35 -0
- package/build/src/cookies/drivers/encrypted.d.ts +13 -0
- package/build/src/cookies/drivers/plain.d.ts +9 -0
- package/build/src/cookies/drivers/signed.d.ts +13 -0
- package/build/src/cookies/parser.d.ts +18 -0
- package/build/src/cookies/serializer.d.ts +20 -0
- package/build/src/define_config.d.ts +1 -3
- package/build/src/define_middleware.d.ts +1 -1
- package/build/src/exception_handler.d.ts +72 -31
- package/build/src/helpers.d.ts +50 -0
- package/build/src/helpers.js +5 -1
- package/build/src/http_context/local_storage.d.ts +17 -0
- package/build/src/http_context/main.d.ts +8 -0
- package/build/src/qs.d.ts +14 -0
- package/build/src/redirect.d.ts +27 -11
- package/build/src/request.d.ts +109 -10
- package/build/src/response.d.ts +399 -203
- package/build/src/router/brisk.d.ts +15 -4
- package/build/src/router/executor.d.ts +4 -0
- package/build/src/router/factories/use_return_value.d.ts +5 -0
- package/build/src/router/group.d.ts +17 -0
- package/build/src/router/legacy/url_builder.d.ts +7 -0
- package/build/src/router/main.d.ts +72 -1
- package/build/src/router/matchers.d.ts +3 -0
- package/build/src/router/resource.d.ts +33 -0
- package/build/src/router/route.d.ts +8 -0
- package/build/src/router/signed_url_builder.d.ts +4 -8
- package/build/src/router/store.d.ts +9 -0
- package/build/src/router/url_builder.d.ts +4 -9
- package/build/src/server/factories/middleware_handler.d.ts +10 -1
- package/build/src/server/factories/route_finder.d.ts +13 -3
- package/build/src/server/factories/write_response.d.ts +9 -2
- package/build/src/server/main.d.ts +77 -23
- package/build/src/tracing_channels.d.ts +4 -4
- package/build/src/types/middleware.d.ts +33 -8
- package/build/src/types/qs.d.ts +5 -0
- package/build/src/types/request.d.ts +1 -1
- package/build/src/types/response.d.ts +14 -6
- package/build/src/types/route.d.ts +40 -17
- package/build/src/types/server.d.ts +26 -11
- package/build/src/types/tracing_channels.d.ts +21 -3
- package/build/src/types/url_builder.d.ts +41 -28
- package/package.json +15 -13
|
@@ -3,29 +3,33 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { type Prettify } from '@poppinss/utils/types';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Configuration options for URL generation helpers
|
|
7
7
|
*/
|
|
8
8
|
export type URLOptions = {
|
|
9
|
+
/** Query string parameters to append to the URL */
|
|
9
10
|
qs?: Record<string, any>;
|
|
11
|
+
/** URL prefix to prepend to the generated URL */
|
|
10
12
|
prefixUrl?: string;
|
|
11
13
|
};
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
15
|
+
* Configuration options for signed URL generation helpers
|
|
14
16
|
*/
|
|
15
17
|
export type SignedURLOptions = URLOptions & {
|
|
18
|
+
/** Expiration time for the signed URL */
|
|
16
19
|
expiresIn?: string | number;
|
|
20
|
+
/** Purpose identifier for the signed URL */
|
|
17
21
|
purpose?: string;
|
|
18
22
|
};
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
24
|
+
* Utility type that constructs function arguments for route URL builders based on route parameters
|
|
21
25
|
*/
|
|
22
|
-
export type RouteBuilderArguments<
|
|
26
|
+
export type RouteBuilderArguments<Identifier, Route, Options extends any = URLOptions> = Route extends LookupListRoute ? Prettify<Route['params'] extends undefined ? [identifier: Identifier, params?: undefined, options?: Options] : [undefined] extends [Route['params']] ? [
|
|
23
27
|
identifier: Identifier,
|
|
24
|
-
params?:
|
|
28
|
+
params?: Route['params'] | Route['paramsTuple'],
|
|
25
29
|
options?: Options
|
|
26
30
|
] : [
|
|
27
31
|
identifier: Identifier,
|
|
28
|
-
params:
|
|
32
|
+
params: Route['params'] | Route['paramsTuple'],
|
|
29
33
|
options?: Options
|
|
30
34
|
]> : never;
|
|
31
35
|
/**
|
|
@@ -35,14 +39,25 @@ export type RouteBuilderArguments<Routes, Method extends keyof Routes, Identifie
|
|
|
35
39
|
* There is no runtime property that matches this type. Its
|
|
36
40
|
* purely for type-inference.
|
|
37
41
|
*/
|
|
42
|
+
/**
|
|
43
|
+
* Route definition structure for type-safe URL building
|
|
44
|
+
*/
|
|
45
|
+
export type LookupListRoute = {
|
|
46
|
+
/** Parameters as a tuple for positional arguments */
|
|
47
|
+
paramsTuple?: [...any[]];
|
|
48
|
+
/** Parameters as a named object */
|
|
49
|
+
params?: {
|
|
50
|
+
[name: string]: any;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Complete route lookup structure organized by HTTP methods and route identifiers
|
|
55
|
+
*/
|
|
38
56
|
export type LookupList = {
|
|
57
|
+
/** HTTP method to route mapping */
|
|
39
58
|
[method: string]: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
params?: {
|
|
43
|
-
[name: string]: any;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
59
|
+
/** Route identifier to route definition mapping */
|
|
60
|
+
[identifier: string]: LookupListRoute;
|
|
46
61
|
};
|
|
47
62
|
};
|
|
48
63
|
/**
|
|
@@ -57,7 +72,7 @@ export type LookupList = {
|
|
|
57
72
|
* urlFor('blog.adonisjs.com@posts.show', [1]) // /posts/1
|
|
58
73
|
* ```
|
|
59
74
|
*/
|
|
60
|
-
export type UrlFor<Routes extends LookupList, Options extends any = URLOptions> = (<Identifier extends keyof Routes['ALL'] & string>(...[identifier, params, options]: RouteBuilderArguments<
|
|
75
|
+
export type UrlFor<Routes extends LookupList, Options extends any = URLOptions> = (<Identifier extends keyof Routes['ALL'] & string>(...[identifier, params, options]: RouteBuilderArguments<Identifier, Routes['ALL'][Identifier], Options>) => string) & {
|
|
61
76
|
/**
|
|
62
77
|
* Make URL for a GET route. An error will be raised if the route doesn't
|
|
63
78
|
* exist.
|
|
@@ -67,7 +82,7 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
|
|
|
67
82
|
* urlFor.get('users.store', [1]) // Error: Route not found GET@users/store
|
|
68
83
|
* ```
|
|
69
84
|
*/
|
|
70
|
-
get<RouteIdentifier extends keyof Routes['GET'] & string>(...[identifier, params, options]: RouteBuilderArguments<
|
|
85
|
+
get<RouteIdentifier extends keyof Routes['GET'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['GET'][RouteIdentifier], Options>): {
|
|
71
86
|
method: 'get';
|
|
72
87
|
url: string;
|
|
73
88
|
};
|
|
@@ -80,7 +95,7 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
|
|
|
80
95
|
* urlFor.post('users.show', [1]) // Error: Route not found POST@users.show
|
|
81
96
|
* ```
|
|
82
97
|
*/
|
|
83
|
-
post<RouteIdentifier extends keyof Routes['POST'] & string>(...[identifier, params, options]: RouteBuilderArguments<
|
|
98
|
+
post<RouteIdentifier extends keyof Routes['POST'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['POST'][RouteIdentifier], Options>): {
|
|
84
99
|
method: 'post';
|
|
85
100
|
url: string;
|
|
86
101
|
};
|
|
@@ -93,7 +108,7 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
|
|
|
93
108
|
* urlFor.put('users.show', [1]) // Error: Route not found PUT@users.show
|
|
94
109
|
* ```
|
|
95
110
|
*/
|
|
96
|
-
put<RouteIdentifier extends keyof Routes['PUT'] & string>(...[identifier, params, options]: RouteBuilderArguments<
|
|
111
|
+
put<RouteIdentifier extends keyof Routes['PUT'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['PUT'][RouteIdentifier], Options>): {
|
|
97
112
|
method: 'put';
|
|
98
113
|
url: string;
|
|
99
114
|
};
|
|
@@ -106,7 +121,7 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
|
|
|
106
121
|
* urlFor.put('users.show', [1]) // Error: Route not found PATCH@users.show
|
|
107
122
|
* ```
|
|
108
123
|
*/
|
|
109
|
-
patch<RouteIdentifier extends keyof Routes['PATCH'] & string>(...[identifier, params, options]: RouteBuilderArguments<
|
|
124
|
+
patch<RouteIdentifier extends keyof Routes['PATCH'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['PATCH'][RouteIdentifier], Options>): {
|
|
110
125
|
method: 'patch';
|
|
111
126
|
url: string;
|
|
112
127
|
};
|
|
@@ -119,7 +134,7 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
|
|
|
119
134
|
* urlFor.delete('users.show', [1]) // Error: Route not found DELETE@users.show
|
|
120
135
|
* ```
|
|
121
136
|
*/
|
|
122
|
-
delete<RouteIdentifier extends keyof Routes['DELETE'] & string>(...[identifier, params, options]: RouteBuilderArguments<
|
|
137
|
+
delete<RouteIdentifier extends keyof Routes['DELETE'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['DELETE'][RouteIdentifier], Options>): {
|
|
123
138
|
method: 'delete';
|
|
124
139
|
url: string;
|
|
125
140
|
};
|
|
@@ -127,21 +142,19 @@ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions>
|
|
|
127
142
|
* Make URL for a custom route method. An error will be raised if the route doesn't
|
|
128
143
|
* exist for the same method.
|
|
129
144
|
*/
|
|
130
|
-
method<Method extends keyof Routes & string, RouteIdentifier extends keyof Routes[Method] & string>(method: Method, ...[identifier, params, options]: RouteBuilderArguments<
|
|
145
|
+
method<Method extends keyof Routes & string, RouteIdentifier extends keyof Routes[Method] & string>(method: Method, ...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes[Method][RouteIdentifier], Options>): {
|
|
131
146
|
method: Method;
|
|
132
147
|
url: string;
|
|
133
148
|
};
|
|
134
149
|
};
|
|
135
150
|
/**
|
|
136
|
-
*
|
|
137
|
-
* and the LookupStore
|
|
151
|
+
* Utility type to extract routes for a specific HTTP method from the routes collection
|
|
138
152
|
*/
|
|
139
|
-
export
|
|
140
|
-
|
|
153
|
+
export type GetRoutesForMethod<Routes, Method> = {
|
|
154
|
+
[K in keyof Routes]: Method extends K ? Routes[Method] : never;
|
|
155
|
+
}[keyof Routes];
|
|
141
156
|
/**
|
|
142
|
-
*
|
|
143
|
-
* RoutesList is extended in the userland code.
|
|
157
|
+
* Interface to be augmented by the router containing all registered routes for type-safe URL generation
|
|
144
158
|
*/
|
|
145
|
-
export
|
|
146
|
-
|
|
147
|
-
};
|
|
159
|
+
export interface RoutesList {
|
|
160
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/http-server",
|
|
3
|
-
"version": "8.0.0-next.
|
|
3
|
+
"version": "8.0.0-next.6",
|
|
4
4
|
"description": "AdonisJS HTTP server with support packed with Routing and Cookies",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"format": "prettier --write .",
|
|
33
33
|
"prepublishOnly": "npm run build",
|
|
34
34
|
"lint": "eslint",
|
|
35
|
-
"quick:test": "node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts"
|
|
35
|
+
"quick:test": "node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts",
|
|
36
|
+
"docs": "typedoc"
|
|
36
37
|
},
|
|
37
38
|
"keywords": [
|
|
38
39
|
"http",
|
|
@@ -41,12 +42,12 @@
|
|
|
41
42
|
"author": "virk,adonisjs",
|
|
42
43
|
"license": "MIT",
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@adonisjs/application": "^9.0.0-next.
|
|
45
|
-
"@adonisjs/encryption": "^7.0.0-next.
|
|
46
|
-
"@adonisjs/eslint-config": "^3.0.0-next.
|
|
47
|
-
"@adonisjs/events": "^10.1.0-next.
|
|
48
|
-
"@adonisjs/fold": "^11.0.0-next.
|
|
49
|
-
"@adonisjs/logger": "^7.
|
|
45
|
+
"@adonisjs/application": "^9.0.0-next.4",
|
|
46
|
+
"@adonisjs/encryption": "^7.0.0-next.1",
|
|
47
|
+
"@adonisjs/eslint-config": "^3.0.0-next.1",
|
|
48
|
+
"@adonisjs/events": "^10.1.0-next.2",
|
|
49
|
+
"@adonisjs/fold": "^11.0.0-next.2",
|
|
50
|
+
"@adonisjs/logger": "^7.1.0-next.0",
|
|
50
51
|
"@adonisjs/prettier-config": "^1.4.5",
|
|
51
52
|
"@adonisjs/tsconfig": "^2.0.0-next.0",
|
|
52
53
|
"@fastify/middie": "^9.0.3",
|
|
@@ -88,6 +89,7 @@
|
|
|
88
89
|
"release-it": "^19.0.4",
|
|
89
90
|
"supertest": "^7.1.4",
|
|
90
91
|
"tsup": "^8.5.0",
|
|
92
|
+
"typedoc": "^0.28.11",
|
|
91
93
|
"typescript": "^5.9.2",
|
|
92
94
|
"youch": "^4.1.0-beta.11"
|
|
93
95
|
},
|
|
@@ -113,11 +115,11 @@
|
|
|
113
115
|
"vary": "^1.1.2"
|
|
114
116
|
},
|
|
115
117
|
"peerDependencies": {
|
|
116
|
-
"@adonisjs/application": "^9.0.0-next.
|
|
117
|
-
"@adonisjs/encryption": "^7.0.0-next.
|
|
118
|
-
"@adonisjs/events": "^10.1.0-next.
|
|
119
|
-
"@adonisjs/fold": "^11.0.0-next.
|
|
120
|
-
"@adonisjs/logger": "^7.
|
|
118
|
+
"@adonisjs/application": "^9.0.0-next.4",
|
|
119
|
+
"@adonisjs/encryption": "^7.0.0-next.1",
|
|
120
|
+
"@adonisjs/events": "^10.1.0-next.2",
|
|
121
|
+
"@adonisjs/fold": "^11.0.0-next.2",
|
|
122
|
+
"@adonisjs/logger": "^7.1.0-next.0",
|
|
121
123
|
"youch": "^4.1.0-beta.11"
|
|
122
124
|
},
|
|
123
125
|
"peerDependenciesMeta": {
|