@adonisjs/http-server 7.7.0 → 8.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/chunk-ASX56VAK.js +76 -0
- package/build/{chunk-6FSCILWX.js → chunk-VYBTM3NC.js} +1022 -611
- package/build/client.cjs +232 -0
- package/build/client.d.cts +258 -0
- package/build/client.d.ts +258 -0
- package/build/client.js +229 -0
- package/build/factories/http_server.d.ts +1 -1
- package/build/factories/main.d.ts +3 -3
- package/build/factories/main.js +87 -87
- package/build/factories/request.d.ts +1 -1
- package/build/factories/response.d.ts +2 -2
- package/build/factories/url_builder_factory.d.ts +25 -0
- package/build/index.d.ts +3 -2
- package/build/index.js +25 -23
- package/build/src/client/main.d.ts +3 -0
- package/build/src/client/router.d.ts +68 -0
- package/build/src/client/types.d.ts +181 -0
- package/build/src/client/url_builder.d.ts +13 -0
- package/build/src/cookies/client.d.ts +2 -2
- package/build/src/cookies/parser.d.ts +2 -2
- package/build/src/cookies/serializer.d.ts +7 -1
- package/build/src/define_middleware.d.ts +3 -2
- package/build/src/{exceptions.d.ts → errors.d.ts} +13 -1
- package/build/src/exception_handler.d.ts +2 -2
- package/build/src/helpers.d.ts +51 -15
- package/build/src/helpers.js +18 -0
- package/build/src/http_context/main.d.ts +3 -3
- package/build/src/qs.d.ts +3 -3
- package/build/src/redirect.d.ts +3 -2
- package/build/src/request.d.ts +10 -9
- package/build/src/response.d.ts +1 -1
- package/build/src/router/brisk.d.ts +4 -3
- package/build/src/router/executor.d.ts +2 -2
- package/build/src/router/factories/use_return_value.d.ts +6 -1
- package/build/src/router/group.d.ts +4 -4
- package/build/src/router/{lookup_store → legacy}/url_builder.d.ts +20 -4
- package/build/src/router/main.d.ts +52 -12
- package/build/src/router/resource.d.ts +4 -3
- package/build/src/router/route.d.ts +3 -2
- package/build/src/router/signed_url_builder.d.ts +14 -0
- package/build/src/router/store.d.ts +3 -2
- package/build/src/server/factories/middleware_handler.d.ts +3 -3
- package/build/src/server/factories/{final_handler.d.ts → route_finder.d.ts} +2 -2
- package/build/src/server/main.d.ts +7 -3
- package/build/src/tracing_channels.d.ts +23 -0
- package/build/src/types/main.d.ts +7 -7
- package/build/src/types/main.js +0 -1
- package/build/src/types/middleware.d.ts +34 -1
- package/build/src/types/request.d.ts +4 -0
- package/build/src/types/response.d.ts +1 -1
- package/build/src/types/route.d.ts +50 -51
- package/build/src/types/server.d.ts +1 -1
- package/build/src/types/tracing_channels.d.ts +6 -0
- package/build/src/utils.d.ts +28 -0
- package/package.json +49 -37
- package/build/chunk-6FSCILWX.js.map +0 -1
- package/build/factories/main.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/src/router/lookup_store/main.d.ts +0 -48
- package/build/src/router/lookup_store/route_finder.d.ts +0 -25
- package/build/src/router/parser.d.ts +0 -5
- package/build/src/types/base.d.ts +0 -19
- package/build/src/types/main.js.map +0 -1
|
@@ -1,22 +1,211 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
__export,
|
|
3
|
+
default as default2,
|
|
4
|
+
default2 as default3,
|
|
5
|
+
parseRoute,
|
|
6
|
+
serializeCookie
|
|
7
|
+
} from "./chunk-ASX56VAK.js";
|
|
8
|
+
|
|
9
|
+
// src/errors.ts
|
|
10
|
+
var errors_exports = {};
|
|
11
|
+
__export(errors_exports, {
|
|
12
|
+
E_CANNOT_LOOKUP_ROUTE: () => E_CANNOT_LOOKUP_ROUTE,
|
|
13
|
+
E_HTTP_EXCEPTION: () => E_HTTP_EXCEPTION,
|
|
14
|
+
E_HTTP_REQUEST_ABORTED: () => E_HTTP_REQUEST_ABORTED,
|
|
15
|
+
E_ROUTE_NOT_FOUND: () => E_ROUTE_NOT_FOUND
|
|
16
|
+
});
|
|
17
|
+
import { createError, Exception } from "@poppinss/utils/exception";
|
|
18
|
+
var E_ROUTE_NOT_FOUND = createError(
|
|
19
|
+
"Cannot %s:%s",
|
|
20
|
+
"E_ROUTE_NOT_FOUND",
|
|
21
|
+
404
|
|
22
|
+
);
|
|
23
|
+
var E_CANNOT_LOOKUP_ROUTE = createError(
|
|
24
|
+
'Cannot lookup route "%s"',
|
|
25
|
+
"E_CANNOT_LOOKUP_ROUTE",
|
|
26
|
+
500
|
|
27
|
+
);
|
|
28
|
+
var E_HTTP_EXCEPTION = class HttpException extends Exception {
|
|
29
|
+
body;
|
|
30
|
+
static code = "E_HTTP_EXCEPTION";
|
|
31
|
+
/**
|
|
32
|
+
* This method returns an instance of the exception class
|
|
33
|
+
*/
|
|
34
|
+
static invoke(body, status, code = "E_HTTP_EXCEPTION") {
|
|
35
|
+
if (body === null || body === void 0) {
|
|
36
|
+
const error2 = new this("HTTP Exception", { status, code });
|
|
37
|
+
error2.body = "Internal server error";
|
|
38
|
+
return error2;
|
|
39
|
+
}
|
|
40
|
+
if (typeof body === "object") {
|
|
41
|
+
const error2 = new this(body.message || "HTTP Exception", { status, code });
|
|
42
|
+
error2.body = body;
|
|
43
|
+
return error2;
|
|
44
|
+
}
|
|
45
|
+
const error = new this(body, { status, code });
|
|
46
|
+
error.body = body;
|
|
47
|
+
return error;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var E_HTTP_REQUEST_ABORTED = class AbortException extends E_HTTP_EXCEPTION {
|
|
51
|
+
handle(error, ctx) {
|
|
52
|
+
ctx.response.status(error.status).send(error.body);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/cookies/drivers/plain.ts
|
|
57
|
+
import base64 from "@poppinss/utils/base64";
|
|
58
|
+
import { MessageBuilder } from "@poppinss/utils";
|
|
59
|
+
function pack(value) {
|
|
60
|
+
if (value === void 0 || value === null) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return base64.urlEncode(new MessageBuilder().build(value));
|
|
64
|
+
}
|
|
65
|
+
function canUnpack(encodedValue) {
|
|
66
|
+
return typeof encodedValue === "string";
|
|
67
|
+
}
|
|
68
|
+
function unpack(encodedValue) {
|
|
69
|
+
return new MessageBuilder().verify(base64.urlDecode(encodedValue, "utf-8", false));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/cookies/drivers/signed.ts
|
|
73
|
+
function pack2(key, value, encryption) {
|
|
74
|
+
if (value === void 0 || value === null) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return `s:${encryption.verifier.sign(value, void 0, key)}`;
|
|
78
|
+
}
|
|
79
|
+
function canUnpack2(signedValue) {
|
|
80
|
+
return typeof signedValue === "string" && signedValue.substring(0, 2) === "s:";
|
|
81
|
+
}
|
|
82
|
+
function unpack2(key, signedValue, encryption) {
|
|
83
|
+
const value = signedValue.slice(2);
|
|
84
|
+
if (!value) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return encryption.verifier.unsign(value, key);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/cookies/drivers/encrypted.ts
|
|
91
|
+
function pack3(key, value, encryption) {
|
|
92
|
+
if (value === void 0 || value === null) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return `e:${encryption.encrypt(value, void 0, key)}`;
|
|
96
|
+
}
|
|
97
|
+
function canUnpack3(encryptedValue) {
|
|
98
|
+
return typeof encryptedValue === "string" && encryptedValue.substring(0, 2) === "e:";
|
|
99
|
+
}
|
|
100
|
+
function unpack3(key, encryptedValue, encryption) {
|
|
101
|
+
const value = encryptedValue.slice(2);
|
|
102
|
+
if (!value) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return encryption.decrypt(value, key);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/cookies/client.ts
|
|
109
|
+
var CookieClient = class {
|
|
110
|
+
#encryption;
|
|
111
|
+
constructor(encryption) {
|
|
112
|
+
this.#encryption = encryption;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Encrypt a key value pair to be sent in the cookie header
|
|
116
|
+
*/
|
|
117
|
+
encrypt(key, value) {
|
|
118
|
+
return pack3(key, value, this.#encryption);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Sign a key value pair to be sent in the cookie header
|
|
122
|
+
*/
|
|
123
|
+
sign(key, value) {
|
|
124
|
+
return pack2(key, value, this.#encryption);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Encode a key value pair to be sent in the cookie header
|
|
128
|
+
*/
|
|
129
|
+
encode(_, value, stringify2 = true) {
|
|
130
|
+
return stringify2 ? pack(value) : value;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Unsign a signed cookie value
|
|
134
|
+
*/
|
|
135
|
+
unsign(key, value) {
|
|
136
|
+
return canUnpack2(value) ? unpack2(key, value, this.#encryption) : null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Decrypt an encrypted cookie value
|
|
140
|
+
*/
|
|
141
|
+
decrypt(key, value) {
|
|
142
|
+
return canUnpack3(value) ? unpack3(key, value, this.#encryption) : null;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Decode an encoded cookie value
|
|
146
|
+
*/
|
|
147
|
+
decode(_, value, stringified = true) {
|
|
148
|
+
if (!stringified) {
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
return canUnpack(value) ? unpack(value) : null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Parse response cookie
|
|
155
|
+
*/
|
|
156
|
+
parse(key, value) {
|
|
157
|
+
if (canUnpack2(value)) {
|
|
158
|
+
return unpack2(key, value, this.#encryption);
|
|
159
|
+
}
|
|
160
|
+
if (canUnpack3(value)) {
|
|
161
|
+
return unpack3(key, value, this.#encryption);
|
|
162
|
+
}
|
|
163
|
+
if (canUnpack(value)) {
|
|
164
|
+
return unpack(value);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
5
167
|
};
|
|
6
168
|
|
|
169
|
+
// src/tracing_channels.ts
|
|
170
|
+
var tracing_channels_exports = {};
|
|
171
|
+
__export(tracing_channels_exports, {
|
|
172
|
+
httpExceptionHandler: () => httpExceptionHandler,
|
|
173
|
+
httpMiddleware: () => httpMiddleware,
|
|
174
|
+
httpRequest: () => httpRequest,
|
|
175
|
+
httpResponseSerializer: () => httpResponseSerializer,
|
|
176
|
+
httpRouteHandler: () => httpRouteHandler
|
|
177
|
+
});
|
|
178
|
+
import diagnostics_channel from "diagnostics_channel";
|
|
179
|
+
var httpRequest = diagnostics_channel.tracingChannel("adonisjs:http.request");
|
|
180
|
+
var httpMiddleware = diagnostics_channel.tracingChannel("adonisjs:http.middleware");
|
|
181
|
+
var httpExceptionHandler = diagnostics_channel.tracingChannel(
|
|
182
|
+
"adonisjs:http.exception.handler"
|
|
183
|
+
);
|
|
184
|
+
var httpRouteHandler = diagnostics_channel.tracingChannel("adonisjs:http.route.handler");
|
|
185
|
+
var httpResponseSerializer = diagnostics_channel.tracingChannel(
|
|
186
|
+
"adonisjs:http.response.serializer"
|
|
187
|
+
);
|
|
188
|
+
|
|
7
189
|
// src/router/route.ts
|
|
8
190
|
import is from "@sindresorhus/is";
|
|
9
191
|
import Macroable4 from "@poppinss/macroable";
|
|
10
192
|
import Middleware from "@poppinss/middleware";
|
|
11
|
-
import { RuntimeException as RuntimeException2 } from "@poppinss/utils";
|
|
193
|
+
import { RuntimeException as RuntimeException2 } from "@poppinss/utils/exception";
|
|
12
194
|
import { moduleCaller, moduleImporter } from "@adonisjs/fold";
|
|
13
195
|
|
|
196
|
+
// src/debug.ts
|
|
197
|
+
import { debuglog } from "util";
|
|
198
|
+
var debug_default = debuglog("adonisjs:http");
|
|
199
|
+
|
|
14
200
|
// src/router/factories/use_return_value.ts
|
|
201
|
+
function canWriteResponseBody(value, ctx) {
|
|
202
|
+
return value !== void 0 && // Return value is explicitly defined
|
|
203
|
+
!ctx.response.hasLazyBody && // Lazy body is not set
|
|
204
|
+
value !== ctx.response;
|
|
205
|
+
}
|
|
15
206
|
function useReturnValue(ctx) {
|
|
16
207
|
return function(value) {
|
|
17
|
-
if (value
|
|
18
|
-
!ctx.response.hasLazyBody && // Lazy body is not set
|
|
19
|
-
value !== ctx.response) {
|
|
208
|
+
if (canWriteResponseBody(value, ctx)) {
|
|
20
209
|
ctx.response.send(value);
|
|
21
210
|
}
|
|
22
211
|
};
|
|
@@ -24,22 +213,50 @@ function useReturnValue(ctx) {
|
|
|
24
213
|
|
|
25
214
|
// src/router/executor.ts
|
|
26
215
|
function execute(route, resolver, ctx, errorResponder) {
|
|
27
|
-
return route.middleware.runner().errorHandler((error) => errorResponder(error, ctx)).finalHandler(
|
|
216
|
+
return route.middleware.runner().errorHandler((error) => errorResponder(error, ctx)).finalHandler(() => {
|
|
28
217
|
if (typeof route.handler === "function") {
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
218
|
+
return httpRouteHandler.tracePromise(
|
|
219
|
+
($ctx) => Promise.resolve(route.handler($ctx)),
|
|
220
|
+
route,
|
|
221
|
+
void 0,
|
|
222
|
+
ctx
|
|
223
|
+
).then(useReturnValue(ctx));
|
|
224
|
+
}
|
|
225
|
+
return httpRouteHandler.tracePromise(
|
|
226
|
+
route.handler.handle,
|
|
227
|
+
route,
|
|
228
|
+
void 0,
|
|
229
|
+
resolver,
|
|
230
|
+
ctx
|
|
231
|
+
).then(useReturnValue(ctx));
|
|
32
232
|
}).run(async (middleware, next) => {
|
|
33
233
|
if (typeof middleware === "function") {
|
|
34
|
-
return
|
|
234
|
+
return httpMiddleware.tracePromise(
|
|
235
|
+
middleware,
|
|
236
|
+
middleware,
|
|
237
|
+
void 0,
|
|
238
|
+
ctx,
|
|
239
|
+
next
|
|
240
|
+
);
|
|
35
241
|
}
|
|
36
|
-
return
|
|
242
|
+
return httpMiddleware.tracePromise(
|
|
243
|
+
middleware.handle,
|
|
244
|
+
middleware,
|
|
245
|
+
void 0,
|
|
246
|
+
resolver,
|
|
247
|
+
ctx,
|
|
248
|
+
next,
|
|
249
|
+
middleware.args
|
|
250
|
+
);
|
|
37
251
|
});
|
|
38
252
|
}
|
|
39
253
|
|
|
40
|
-
// src/
|
|
254
|
+
// src/utils.ts
|
|
41
255
|
import Cache from "tmp-cache";
|
|
42
|
-
import { InvalidArgumentsException } from "@poppinss/utils";
|
|
256
|
+
import { InvalidArgumentsException } from "@poppinss/utils/exception";
|
|
257
|
+
|
|
258
|
+
// src/router/group.ts
|
|
259
|
+
import Macroable3 from "@poppinss/macroable";
|
|
43
260
|
|
|
44
261
|
// src/router/brisk.ts
|
|
45
262
|
import Macroable from "@poppinss/macroable";
|
|
@@ -87,7 +304,8 @@ var BriskRoute = class extends Macroable {
|
|
|
87
304
|
* Redirects to a given route. Params from the original request will
|
|
88
305
|
* be used when no custom params are defined.
|
|
89
306
|
*/
|
|
90
|
-
redirect(
|
|
307
|
+
redirect(...args) {
|
|
308
|
+
const [identifier, params, options] = args;
|
|
91
309
|
function redirectsToRoute(ctx) {
|
|
92
310
|
const redirector = ctx.response.redirect();
|
|
93
311
|
if (options?.status) {
|
|
@@ -114,13 +332,10 @@ var BriskRoute = class extends Macroable {
|
|
|
114
332
|
}
|
|
115
333
|
};
|
|
116
334
|
|
|
117
|
-
// src/router/group.ts
|
|
118
|
-
import Macroable3 from "@poppinss/macroable";
|
|
119
|
-
|
|
120
335
|
// src/router/resource.ts
|
|
121
336
|
import string from "@poppinss/utils/string";
|
|
122
337
|
import Macroable2 from "@poppinss/macroable";
|
|
123
|
-
import { RuntimeException } from "@poppinss/utils";
|
|
338
|
+
import { RuntimeException } from "@poppinss/utils/exception";
|
|
124
339
|
var RouteResource = class extends Macroable2 {
|
|
125
340
|
/**
|
|
126
341
|
* Resource identifier. Nested resources are separated
|
|
@@ -534,7 +749,7 @@ var RouteGroup = class _RouteGroup extends Macroable3 {
|
|
|
534
749
|
}
|
|
535
750
|
};
|
|
536
751
|
|
|
537
|
-
// src/
|
|
752
|
+
// src/utils.ts
|
|
538
753
|
var proxyCache = new Cache({ max: 200 });
|
|
539
754
|
function dropSlash(input) {
|
|
540
755
|
if (input === "/") {
|
|
@@ -600,10 +815,65 @@ function parseRange(range, value) {
|
|
|
600
815
|
{}
|
|
601
816
|
);
|
|
602
817
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
818
|
+
function decodeComponentChar(highCharCode, lowCharCode) {
|
|
819
|
+
if (highCharCode === 50) {
|
|
820
|
+
if (lowCharCode === 53) return "%";
|
|
821
|
+
if (lowCharCode === 51) return "#";
|
|
822
|
+
if (lowCharCode === 52) return "$";
|
|
823
|
+
if (lowCharCode === 54) return "&";
|
|
824
|
+
if (lowCharCode === 66) return "+";
|
|
825
|
+
if (lowCharCode === 98) return "+";
|
|
826
|
+
if (lowCharCode === 67) return ",";
|
|
827
|
+
if (lowCharCode === 99) return ",";
|
|
828
|
+
if (lowCharCode === 70) return "/";
|
|
829
|
+
if (lowCharCode === 102) return "/";
|
|
830
|
+
return null;
|
|
831
|
+
}
|
|
832
|
+
if (highCharCode === 51) {
|
|
833
|
+
if (lowCharCode === 65) return ":";
|
|
834
|
+
if (lowCharCode === 97) return ":";
|
|
835
|
+
if (lowCharCode === 66) return ";";
|
|
836
|
+
if (lowCharCode === 98) return ";";
|
|
837
|
+
if (lowCharCode === 68) return "=";
|
|
838
|
+
if (lowCharCode === 100) return "=";
|
|
839
|
+
if (lowCharCode === 70) return "?";
|
|
840
|
+
if (lowCharCode === 102) return "?";
|
|
841
|
+
return null;
|
|
842
|
+
}
|
|
843
|
+
if (highCharCode === 52 && lowCharCode === 48) {
|
|
844
|
+
return "@";
|
|
845
|
+
}
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
function safeDecodeURI(path, useSemicolonDelimiter) {
|
|
849
|
+
let shouldDecode = false;
|
|
850
|
+
let shouldDecodeParam = false;
|
|
851
|
+
let querystring = "";
|
|
852
|
+
for (let i = 1; i < path.length; i++) {
|
|
853
|
+
const charCode = path.charCodeAt(i);
|
|
854
|
+
if (charCode === 37) {
|
|
855
|
+
const highCharCode = path.charCodeAt(i + 1);
|
|
856
|
+
const lowCharCode = path.charCodeAt(i + 2);
|
|
857
|
+
if (decodeComponentChar(highCharCode, lowCharCode) === null) {
|
|
858
|
+
shouldDecode = true;
|
|
859
|
+
} else {
|
|
860
|
+
shouldDecodeParam = true;
|
|
861
|
+
if (highCharCode === 50 && lowCharCode === 53) {
|
|
862
|
+
shouldDecode = true;
|
|
863
|
+
path = path.slice(0, i + 1) + "25" + path.slice(i + 1);
|
|
864
|
+
i += 2;
|
|
865
|
+
}
|
|
866
|
+
i += 2;
|
|
867
|
+
}
|
|
868
|
+
} else if (charCode === 63 || charCode === 35 || charCode === 59 && useSemicolonDelimiter) {
|
|
869
|
+
querystring = path.slice(i + 1);
|
|
870
|
+
path = path.slice(0, i);
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
const decodedPath = shouldDecode ? decodeURI(path) : path;
|
|
875
|
+
return { pathname: decodedPath, query: querystring, shouldDecodeParam };
|
|
876
|
+
}
|
|
607
877
|
|
|
608
878
|
// src/router/route.ts
|
|
609
879
|
var Route = class extends Macroable4 {
|
|
@@ -850,16 +1120,20 @@ var Route = class extends Macroable4 {
|
|
|
850
1120
|
debug_default("adding named middleware to route %s, %O", this.#pattern, one);
|
|
851
1121
|
middleware.add(one);
|
|
852
1122
|
});
|
|
1123
|
+
middleware.freeze();
|
|
853
1124
|
return middleware;
|
|
854
1125
|
}
|
|
855
1126
|
/**
|
|
856
1127
|
* Returns JSON representation of the route
|
|
857
1128
|
*/
|
|
858
1129
|
toJSON() {
|
|
1130
|
+
const pattern = this.#computePattern();
|
|
1131
|
+
const matchers = this.#getMatchers();
|
|
859
1132
|
return {
|
|
860
1133
|
domain: this.#routeDomain,
|
|
861
|
-
pattern
|
|
862
|
-
matchers
|
|
1134
|
+
pattern,
|
|
1135
|
+
matchers,
|
|
1136
|
+
tokens: parseRoute(pattern, matchers),
|
|
863
1137
|
meta: {},
|
|
864
1138
|
name: this.#name,
|
|
865
1139
|
handler: this.#handler,
|
|
@@ -870,135 +1144,24 @@ var Route = class extends Macroable4 {
|
|
|
870
1144
|
}
|
|
871
1145
|
};
|
|
872
1146
|
|
|
873
|
-
// src/
|
|
874
|
-
import
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
}
|
|
884
|
-
function unpack(encodedValue) {
|
|
885
|
-
return new MessageBuilder().verify(base64.urlDecode(encodedValue, "utf-8", false));
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
// src/cookies/drivers/signed.ts
|
|
889
|
-
function pack2(key, value, encryption) {
|
|
890
|
-
if (value === void 0 || value === null) {
|
|
891
|
-
return null;
|
|
892
|
-
}
|
|
893
|
-
return `s:${encryption.verifier.sign(value, void 0, key)}`;
|
|
894
|
-
}
|
|
895
|
-
function canUnpack2(signedValue) {
|
|
896
|
-
return typeof signedValue === "string" && signedValue.substring(0, 2) === "s:";
|
|
897
|
-
}
|
|
898
|
-
function unpack2(key, signedValue, encryption) {
|
|
899
|
-
const value = signedValue.slice(2);
|
|
900
|
-
if (!value) {
|
|
901
|
-
return null;
|
|
902
|
-
}
|
|
903
|
-
return encryption.verifier.unsign(value, key);
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
// src/cookies/drivers/encrypted.ts
|
|
907
|
-
function pack3(key, value, encryption) {
|
|
908
|
-
if (value === void 0 || value === null) {
|
|
909
|
-
return null;
|
|
910
|
-
}
|
|
911
|
-
return `e:${encryption.encrypt(value, void 0, key)}`;
|
|
912
|
-
}
|
|
913
|
-
function canUnpack3(encryptedValue) {
|
|
914
|
-
return typeof encryptedValue === "string" && encryptedValue.substring(0, 2) === "e:";
|
|
915
|
-
}
|
|
916
|
-
function unpack3(key, encryptedValue, encryption) {
|
|
917
|
-
const value = encryptedValue.slice(2);
|
|
918
|
-
if (!value) {
|
|
919
|
-
return null;
|
|
920
|
-
}
|
|
921
|
-
return encryption.decrypt(value, key);
|
|
922
|
-
}
|
|
1147
|
+
// src/request.ts
|
|
1148
|
+
import fresh from "fresh";
|
|
1149
|
+
import typeIs from "type-is";
|
|
1150
|
+
import accepts from "accepts";
|
|
1151
|
+
import { isIP } from "net";
|
|
1152
|
+
import is2 from "@sindresorhus/is";
|
|
1153
|
+
import proxyaddr from "proxy-addr";
|
|
1154
|
+
import { safeEqual } from "@poppinss/utils";
|
|
1155
|
+
import Macroable5 from "@poppinss/macroable";
|
|
1156
|
+
import lodash from "@poppinss/utils/lodash";
|
|
923
1157
|
|
|
924
|
-
// src/cookies/
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
this.#encryption = encryption;
|
|
929
|
-
}
|
|
1158
|
+
// src/cookies/parser.ts
|
|
1159
|
+
import cookie from "cookie";
|
|
1160
|
+
var CookieParser = class {
|
|
1161
|
+
#client;
|
|
930
1162
|
/**
|
|
931
|
-
*
|
|
932
|
-
|
|
933
|
-
encrypt(key, value) {
|
|
934
|
-
return pack3(key, value, this.#encryption);
|
|
935
|
-
}
|
|
936
|
-
/**
|
|
937
|
-
* Sign a key value pair to be sent in the cookie header
|
|
938
|
-
*/
|
|
939
|
-
sign(key, value) {
|
|
940
|
-
return pack2(key, value, this.#encryption);
|
|
941
|
-
}
|
|
942
|
-
/**
|
|
943
|
-
* Encode a key value pair to be sent in the cookie header
|
|
944
|
-
*/
|
|
945
|
-
encode(_, value) {
|
|
946
|
-
return pack(value);
|
|
947
|
-
}
|
|
948
|
-
/**
|
|
949
|
-
* Unsign a signed cookie value
|
|
950
|
-
*/
|
|
951
|
-
unsign(key, value) {
|
|
952
|
-
return canUnpack2(value) ? unpack2(key, value, this.#encryption) : null;
|
|
953
|
-
}
|
|
954
|
-
/**
|
|
955
|
-
* Decrypt an encrypted cookie value
|
|
956
|
-
*/
|
|
957
|
-
decrypt(key, value) {
|
|
958
|
-
return canUnpack3(value) ? unpack3(key, value, this.#encryption) : null;
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* Decode an encoded cookie value
|
|
962
|
-
*/
|
|
963
|
-
decode(_, value) {
|
|
964
|
-
return canUnpack(value) ? unpack(value) : null;
|
|
965
|
-
}
|
|
966
|
-
/**
|
|
967
|
-
* Parse response cookie
|
|
968
|
-
*/
|
|
969
|
-
parse(key, value) {
|
|
970
|
-
if (canUnpack2(value)) {
|
|
971
|
-
return unpack2(key, value, this.#encryption);
|
|
972
|
-
}
|
|
973
|
-
if (canUnpack3(value)) {
|
|
974
|
-
return unpack3(key, value, this.#encryption);
|
|
975
|
-
}
|
|
976
|
-
if (canUnpack(value)) {
|
|
977
|
-
return unpack(value);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
|
|
982
|
-
// src/request.ts
|
|
983
|
-
import fresh from "fresh";
|
|
984
|
-
import typeIs from "type-is";
|
|
985
|
-
import accepts from "accepts";
|
|
986
|
-
import { isIP } from "net";
|
|
987
|
-
import is2 from "@sindresorhus/is";
|
|
988
|
-
import proxyaddr from "proxy-addr";
|
|
989
|
-
import { safeEqual } from "@poppinss/utils";
|
|
990
|
-
import Macroable5 from "@poppinss/macroable";
|
|
991
|
-
import lodash from "@poppinss/utils/lodash";
|
|
992
|
-
import { createId } from "@paralleldrive/cuid2";
|
|
993
|
-
import { parse } from "url";
|
|
994
|
-
|
|
995
|
-
// src/cookies/parser.ts
|
|
996
|
-
import cookie from "cookie";
|
|
997
|
-
var CookieParser = class {
|
|
998
|
-
#client;
|
|
999
|
-
/**
|
|
1000
|
-
* A copy of cached cookies, they are cached during a request after
|
|
1001
|
-
* initial decoding, unsigning or decrypting.
|
|
1163
|
+
* A copy of cached cookies, they are cached during a request after
|
|
1164
|
+
* initial decoding, unsigning or decrypting.
|
|
1002
1165
|
*/
|
|
1003
1166
|
#cachedCookies = {
|
|
1004
1167
|
signedCookies: {},
|
|
@@ -1025,10 +1188,10 @@ var CookieParser = class {
|
|
|
1025
1188
|
}
|
|
1026
1189
|
/**
|
|
1027
1190
|
* Attempts to decode a cookie by the name. When calling this method,
|
|
1028
|
-
* you are assuming that the cookie was just
|
|
1191
|
+
* you are assuming that the cookie was just stringified in the first
|
|
1029
1192
|
* place and not signed or encrypted.
|
|
1030
1193
|
*/
|
|
1031
|
-
decode(key,
|
|
1194
|
+
decode(key, stringified = true) {
|
|
1032
1195
|
const value = this.#cookies[key];
|
|
1033
1196
|
if (value === null || value === void 0) {
|
|
1034
1197
|
return null;
|
|
@@ -1037,7 +1200,7 @@ var CookieParser = class {
|
|
|
1037
1200
|
if (cache[key] !== void 0) {
|
|
1038
1201
|
return cache[key];
|
|
1039
1202
|
}
|
|
1040
|
-
const parsed =
|
|
1203
|
+
const parsed = this.#client.decode(key, value, stringified);
|
|
1041
1204
|
if (parsed !== null) {
|
|
1042
1205
|
cache[key] = parsed;
|
|
1043
1206
|
}
|
|
@@ -1100,7 +1263,7 @@ var Request = class extends Macroable5 {
|
|
|
1100
1263
|
this.#qsParser = qsParser;
|
|
1101
1264
|
this.#config = config;
|
|
1102
1265
|
this.#encryption = encryption;
|
|
1103
|
-
this.parsedUrl =
|
|
1266
|
+
this.parsedUrl = safeDecodeURI(request.url, false);
|
|
1104
1267
|
this.#parseQueryString();
|
|
1105
1268
|
}
|
|
1106
1269
|
/**
|
|
@@ -1147,9 +1310,7 @@ var Request = class extends Macroable5 {
|
|
|
1147
1310
|
*/
|
|
1148
1311
|
#cookieParser;
|
|
1149
1312
|
/**
|
|
1150
|
-
*
|
|
1151
|
-
* object. This is done to build URL's with query string without
|
|
1152
|
-
* stringifying the object
|
|
1313
|
+
* Parsed URL with query string stored as a string.
|
|
1153
1314
|
*/
|
|
1154
1315
|
parsedUrl;
|
|
1155
1316
|
/**
|
|
@@ -1189,7 +1350,7 @@ var Request = class extends Macroable5 {
|
|
|
1189
1350
|
id() {
|
|
1190
1351
|
let requestId = this.header("x-request-id");
|
|
1191
1352
|
if (!requestId && this.#config.generateRequestId) {
|
|
1192
|
-
requestId =
|
|
1353
|
+
requestId = this.#config.createRequestId();
|
|
1193
1354
|
this.request.headers["x-request-id"] = requestId;
|
|
1194
1355
|
}
|
|
1195
1356
|
return requestId;
|
|
@@ -1207,14 +1368,7 @@ var Request = class extends Macroable5 {
|
|
|
1207
1368
|
throw new Error('Cannot re-set initial body. Use "request.updateBody" instead');
|
|
1208
1369
|
}
|
|
1209
1370
|
this.updateBody(body);
|
|
1210
|
-
this.#originalRequestData = Object.freeze(
|
|
1211
|
-
lodash.cloneDeepWith(this.#requestData, (value) => {
|
|
1212
|
-
if (is2.primitive(value) || Array.isArray(value) || is2.plainObject(value)) {
|
|
1213
|
-
return void 0;
|
|
1214
|
-
}
|
|
1215
|
-
return null;
|
|
1216
|
-
})
|
|
1217
|
-
);
|
|
1371
|
+
this.#originalRequestData = Object.freeze(lodash.cloneDeep(this.#requestData));
|
|
1218
1372
|
}
|
|
1219
1373
|
/**
|
|
1220
1374
|
* Update the request body with new data object. The `all` property
|
|
@@ -1469,11 +1623,11 @@ var Request = class extends Macroable5 {
|
|
|
1469
1623
|
if ("encrypted" in this.request.socket) {
|
|
1470
1624
|
return "https";
|
|
1471
1625
|
}
|
|
1472
|
-
if (
|
|
1473
|
-
|
|
1626
|
+
if (trustProxy(this.request.socket.remoteAddress, this.#config.trustProxy)) {
|
|
1627
|
+
const forwardedProtocol = this.header("X-Forwarded-Proto");
|
|
1628
|
+
return forwardedProtocol ? forwardedProtocol.split(/\s*,\s*/)[0] : "http";
|
|
1474
1629
|
}
|
|
1475
|
-
|
|
1476
|
-
return forwardedProtocol ? forwardedProtocol.split(/\s*,\s*/)[0] : "http";
|
|
1630
|
+
return "http";
|
|
1477
1631
|
}
|
|
1478
1632
|
/**
|
|
1479
1633
|
* Returns a boolean telling if request is served over `https`
|
|
@@ -1903,8 +2057,7 @@ var Request = class extends Macroable5 {
|
|
|
1903
2057
|
};
|
|
1904
2058
|
|
|
1905
2059
|
// src/redirect.ts
|
|
1906
|
-
import { parse
|
|
1907
|
-
import encodeUrl from "encodeurl";
|
|
2060
|
+
import { parse } from "url";
|
|
1908
2061
|
var Redirect = class {
|
|
1909
2062
|
/**
|
|
1910
2063
|
* A boolean to forward the existing query string
|
|
@@ -1935,7 +2088,7 @@ var Redirect = class {
|
|
|
1935
2088
|
const stringified = this.#qs.stringify(query);
|
|
1936
2089
|
url = stringified ? `${url}?${stringified}` : url;
|
|
1937
2090
|
debug_default('redirecting to url "%s"', url);
|
|
1938
|
-
this.#response.location(
|
|
2091
|
+
this.#response.location(default2(url));
|
|
1939
2092
|
this.#response.safeStatus(this.#statusCode);
|
|
1940
2093
|
this.#response.type("text/plain; charset=utf-8");
|
|
1941
2094
|
this.#response.send(`Redirecting to ${url}`);
|
|
@@ -1981,7 +2134,7 @@ var Redirect = class {
|
|
|
1981
2134
|
back() {
|
|
1982
2135
|
let query = {};
|
|
1983
2136
|
const referrerUrl = this.#getReferrerUrl();
|
|
1984
|
-
const url =
|
|
2137
|
+
const url = parse(referrerUrl);
|
|
1985
2138
|
debug_default('referrer url "%s"', referrerUrl);
|
|
1986
2139
|
debug_default('referrer base url "%s"', url.pathname);
|
|
1987
2140
|
if (this.#forwardQueryString) {
|
|
@@ -1993,12 +2146,13 @@ var Redirect = class {
|
|
|
1993
2146
|
/**
|
|
1994
2147
|
* Redirect the request using a route identifier.
|
|
1995
2148
|
*/
|
|
1996
|
-
toRoute(
|
|
2149
|
+
toRoute(...args) {
|
|
2150
|
+
const [identifier, params, options] = args;
|
|
1997
2151
|
if (options && options.qs) {
|
|
1998
2152
|
this.withQs(options.qs);
|
|
1999
2153
|
options.qs = void 0;
|
|
2000
2154
|
}
|
|
2001
|
-
const url = this.#router.
|
|
2155
|
+
const url = this.#router.urlBuilder.urlFor(identifier, params, options);
|
|
2002
2156
|
return this.toPath(url);
|
|
2003
2157
|
}
|
|
2004
2158
|
/**
|
|
@@ -2007,60 +2161,13 @@ var Redirect = class {
|
|
|
2007
2161
|
toPath(url) {
|
|
2008
2162
|
let query = {};
|
|
2009
2163
|
if (this.#forwardQueryString) {
|
|
2010
|
-
query = this.#qs.parse(
|
|
2164
|
+
query = this.#qs.parse(parse(this.#request.url).query || "");
|
|
2011
2165
|
}
|
|
2012
2166
|
Object.assign(query, this.#queryString);
|
|
2013
2167
|
this.#sendResponse(url, query);
|
|
2014
2168
|
}
|
|
2015
2169
|
};
|
|
2016
2170
|
|
|
2017
|
-
// src/exceptions.ts
|
|
2018
|
-
var exceptions_exports = {};
|
|
2019
|
-
__export(exceptions_exports, {
|
|
2020
|
-
E_CANNOT_LOOKUP_ROUTE: () => E_CANNOT_LOOKUP_ROUTE,
|
|
2021
|
-
E_HTTP_EXCEPTION: () => E_HTTP_EXCEPTION,
|
|
2022
|
-
E_HTTP_REQUEST_ABORTED: () => E_HTTP_REQUEST_ABORTED,
|
|
2023
|
-
E_ROUTE_NOT_FOUND: () => E_ROUTE_NOT_FOUND
|
|
2024
|
-
});
|
|
2025
|
-
import { createError, Exception } from "@poppinss/utils";
|
|
2026
|
-
var E_ROUTE_NOT_FOUND = createError(
|
|
2027
|
-
"Cannot %s:%s",
|
|
2028
|
-
"E_ROUTE_NOT_FOUND",
|
|
2029
|
-
404
|
|
2030
|
-
);
|
|
2031
|
-
var E_CANNOT_LOOKUP_ROUTE = createError(
|
|
2032
|
-
'Cannot lookup route "%s"',
|
|
2033
|
-
"E_CANNOT_LOOKUP_ROUTE",
|
|
2034
|
-
500
|
|
2035
|
-
);
|
|
2036
|
-
var E_HTTP_EXCEPTION = class HttpException extends Exception {
|
|
2037
|
-
body;
|
|
2038
|
-
static code = "E_HTTP_EXCEPTION";
|
|
2039
|
-
/**
|
|
2040
|
-
* This method returns an instance of the exception class
|
|
2041
|
-
*/
|
|
2042
|
-
static invoke(body, status, code = "E_HTTP_EXCEPTION") {
|
|
2043
|
-
if (body === null || body === void 0) {
|
|
2044
|
-
const error2 = new this("HTTP Exception", { status, code });
|
|
2045
|
-
error2.body = "Internal server error";
|
|
2046
|
-
return error2;
|
|
2047
|
-
}
|
|
2048
|
-
if (typeof body === "object") {
|
|
2049
|
-
const error2 = new this(body.message || "HTTP Exception", { status, code });
|
|
2050
|
-
error2.body = body;
|
|
2051
|
-
return error2;
|
|
2052
|
-
}
|
|
2053
|
-
const error = new this(body, { status, code });
|
|
2054
|
-
error.body = body;
|
|
2055
|
-
return error;
|
|
2056
|
-
}
|
|
2057
|
-
};
|
|
2058
|
-
var E_HTTP_REQUEST_ABORTED = class AbortException extends E_HTTP_EXCEPTION {
|
|
2059
|
-
handle(error, ctx) {
|
|
2060
|
-
ctx.response.status(error.status).send(error.body);
|
|
2061
|
-
}
|
|
2062
|
-
};
|
|
2063
|
-
|
|
2064
2171
|
// src/response_status.ts
|
|
2065
2172
|
var ResponseStatus = {
|
|
2066
2173
|
Continue: 100,
|
|
@@ -2128,58 +2235,44 @@ var ResponseStatus = {
|
|
|
2128
2235
|
};
|
|
2129
2236
|
|
|
2130
2237
|
// src/response.ts
|
|
2131
|
-
import { Buffer as Buffer2 } from "buffer";
|
|
2132
2238
|
import etag from "etag";
|
|
2133
2239
|
import vary from "vary";
|
|
2134
2240
|
import fresh2 from "fresh";
|
|
2135
|
-
import mime from "mime-types";
|
|
2136
2241
|
import destroy from "destroy";
|
|
2137
2242
|
import { extname } from "path";
|
|
2243
|
+
import { Buffer } from "buffer";
|
|
2138
2244
|
import onFinished from "on-finished";
|
|
2139
|
-
import
|
|
2245
|
+
import { stat } from "fs/promises";
|
|
2140
2246
|
import Macroable6 from "@poppinss/macroable";
|
|
2141
2247
|
import { createReadStream } from "fs";
|
|
2142
|
-
import { stat } from "fs/promises";
|
|
2143
|
-
import { RuntimeException as RuntimeException3 } from "@poppinss/utils";
|
|
2144
2248
|
import contentDisposition from "content-disposition";
|
|
2249
|
+
import { safeStringify } from "@poppinss/utils/json";
|
|
2250
|
+
import { RuntimeException as RuntimeException3 } from "@poppinss/utils/exception";
|
|
2145
2251
|
|
|
2146
2252
|
// src/cookies/serializer.ts
|
|
2147
|
-
import cookie2 from "cookie";
|
|
2148
|
-
import string2 from "@poppinss/utils/string";
|
|
2149
2253
|
var CookieSerializer = class {
|
|
2150
2254
|
#client;
|
|
2151
2255
|
constructor(encryption) {
|
|
2152
2256
|
this.#client = new CookieClient(encryption);
|
|
2153
2257
|
}
|
|
2154
|
-
/**
|
|
2155
|
-
* Serializes the key-value pair to a string, that can be set on the
|
|
2156
|
-
* `Set-Cookie` header.
|
|
2157
|
-
*/
|
|
2158
|
-
#serializeAsCookie(key, value, options) {
|
|
2159
|
-
let expires = options?.expires;
|
|
2160
|
-
if (typeof expires === "function") {
|
|
2161
|
-
expires = expires();
|
|
2162
|
-
}
|
|
2163
|
-
let maxAge = options?.maxAge ? string2.seconds.parse(options?.maxAge) : void 0;
|
|
2164
|
-
const parsedOptions = Object.assign({}, options, { maxAge, expires });
|
|
2165
|
-
return cookie2.serialize(key, value, parsedOptions);
|
|
2166
|
-
}
|
|
2167
2258
|
/**
|
|
2168
2259
|
* Encodes value as a plain cookie. By default, the plain value will be converted
|
|
2169
2260
|
* to a string using "JSON.stringify" method and then encoded as a base64 string.
|
|
2170
2261
|
*
|
|
2171
|
-
* You can disable
|
|
2262
|
+
* You can disable cookie stringifaction by setting `options.stringify = false`.
|
|
2172
2263
|
*
|
|
2173
2264
|
* ```ts
|
|
2174
2265
|
* serializer.encode('name', 'virk')
|
|
2266
|
+
* serializer.encode('name', 'virk', { stringify: false })
|
|
2175
2267
|
* ```
|
|
2176
2268
|
*/
|
|
2177
2269
|
encode(key, value, options) {
|
|
2178
|
-
const
|
|
2270
|
+
const stringify2 = options?.stringify ?? options?.encode;
|
|
2271
|
+
const packedValue = this.#client.encode(key, value, stringify2);
|
|
2179
2272
|
if (packedValue === null || packedValue === void 0) {
|
|
2180
2273
|
return null;
|
|
2181
2274
|
}
|
|
2182
|
-
return
|
|
2275
|
+
return serializeCookie(key, packedValue, options);
|
|
2183
2276
|
}
|
|
2184
2277
|
/**
|
|
2185
2278
|
* Sign a key-value pair to a signed cookie. The signed value has a
|
|
@@ -2190,7 +2283,7 @@ var CookieSerializer = class {
|
|
|
2190
2283
|
if (packedValue === null) {
|
|
2191
2284
|
return null;
|
|
2192
2285
|
}
|
|
2193
|
-
return
|
|
2286
|
+
return serializeCookie(key, packedValue, options);
|
|
2194
2287
|
}
|
|
2195
2288
|
/**
|
|
2196
2289
|
* Encrypts a key-value pair to an encrypted cookie.
|
|
@@ -2200,7 +2293,7 @@ var CookieSerializer = class {
|
|
|
2200
2293
|
if (packedValue === null) {
|
|
2201
2294
|
return null;
|
|
2202
2295
|
}
|
|
2203
|
-
return
|
|
2296
|
+
return serializeCookie(key, packedValue, options);
|
|
2204
2297
|
}
|
|
2205
2298
|
};
|
|
2206
2299
|
|
|
@@ -2351,20 +2444,20 @@ var Response = class extends Macroable6 {
|
|
|
2351
2444
|
* - Buffer
|
|
2352
2445
|
*/
|
|
2353
2446
|
#getDataType(content) {
|
|
2354
|
-
if (content instanceof Uint8Array) {
|
|
2355
|
-
return "buffer";
|
|
2356
|
-
}
|
|
2357
|
-
if (content instanceof Date) {
|
|
2358
|
-
return "date";
|
|
2359
|
-
}
|
|
2360
|
-
if (content instanceof RegExp) {
|
|
2361
|
-
return "regexp";
|
|
2362
|
-
}
|
|
2363
2447
|
const dataType = typeof content;
|
|
2364
2448
|
if (dataType === "number" || dataType === "boolean" || dataType === "string" || dataType === "bigint") {
|
|
2365
2449
|
return dataType;
|
|
2366
2450
|
}
|
|
2367
2451
|
if (dataType === "object") {
|
|
2452
|
+
if (content instanceof Uint8Array) {
|
|
2453
|
+
return "buffer";
|
|
2454
|
+
}
|
|
2455
|
+
if (content instanceof RegExp) {
|
|
2456
|
+
return "regexp";
|
|
2457
|
+
}
|
|
2458
|
+
if (content instanceof Date) {
|
|
2459
|
+
return "date";
|
|
2460
|
+
}
|
|
2368
2461
|
return "object";
|
|
2369
2462
|
}
|
|
2370
2463
|
throw new RuntimeException3(`Cannot serialize "${dataType}" to HTTP response`);
|
|
@@ -2394,12 +2487,29 @@ var Response = class extends Macroable6 {
|
|
|
2394
2487
|
return;
|
|
2395
2488
|
}
|
|
2396
2489
|
const dataType = this.#getDataType(content);
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2490
|
+
let contentType;
|
|
2491
|
+
switch (dataType) {
|
|
2492
|
+
case "string":
|
|
2493
|
+
contentType = content.trimStart().startsWith("<") ? "text/html; charset=utf-8" : "text/plain; charset=utf-8";
|
|
2494
|
+
break;
|
|
2495
|
+
case "number":
|
|
2496
|
+
case "boolean":
|
|
2497
|
+
case "bigint":
|
|
2498
|
+
case "regexp":
|
|
2499
|
+
content = String(content);
|
|
2500
|
+
contentType = "text/plain; charset=utf-8";
|
|
2501
|
+
break;
|
|
2502
|
+
case "date":
|
|
2503
|
+
content = content.toISOString();
|
|
2504
|
+
contentType = "text/plain; charset=utf-8";
|
|
2505
|
+
break;
|
|
2506
|
+
case "buffer":
|
|
2507
|
+
contentType = "application/octet-stream; charset=utf-8";
|
|
2508
|
+
break;
|
|
2509
|
+
case "object":
|
|
2510
|
+
content = safeStringify(content);
|
|
2511
|
+
contentType = "application/json; charset=utf-8";
|
|
2512
|
+
break;
|
|
2403
2513
|
}
|
|
2404
2514
|
if (jsonpCallbackName) {
|
|
2405
2515
|
content = content.replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
@@ -2416,30 +2526,12 @@ var Response = class extends Macroable6 {
|
|
|
2416
2526
|
return;
|
|
2417
2527
|
}
|
|
2418
2528
|
this.setRequestId();
|
|
2419
|
-
this.header("Content-Length",
|
|
2529
|
+
this.header("Content-Length", Buffer.byteLength(content));
|
|
2420
2530
|
if (jsonpCallbackName) {
|
|
2421
2531
|
this.header("X-Content-Type-Options", "nosniff");
|
|
2422
2532
|
this.safeHeader("Content-Type", "text/javascript; charset=utf-8");
|
|
2423
2533
|
} else {
|
|
2424
|
-
|
|
2425
|
-
case "string":
|
|
2426
|
-
const type = /^\s*</.test(content) ? "text/html" : "text/plain";
|
|
2427
|
-
this.safeHeader("Content-Type", `${type}; charset=utf-8`);
|
|
2428
|
-
break;
|
|
2429
|
-
case "number":
|
|
2430
|
-
case "boolean":
|
|
2431
|
-
case "date":
|
|
2432
|
-
case "bigint":
|
|
2433
|
-
case "regexp":
|
|
2434
|
-
this.safeHeader("Content-Type", "text/plain; charset=utf-8");
|
|
2435
|
-
break;
|
|
2436
|
-
case "buffer":
|
|
2437
|
-
this.safeHeader("Content-Type", "application/octet-stream; charset=utf-8");
|
|
2438
|
-
break;
|
|
2439
|
-
case "object":
|
|
2440
|
-
this.safeHeader("Content-Type", "application/json; charset=utf-8");
|
|
2441
|
-
break;
|
|
2442
|
-
}
|
|
2534
|
+
this.safeHeader("Content-type", contentType);
|
|
2443
2535
|
}
|
|
2444
2536
|
this.#endResponse(content);
|
|
2445
2537
|
}
|
|
@@ -2676,7 +2768,7 @@ var Response = class extends Macroable6 {
|
|
|
2676
2768
|
*/
|
|
2677
2769
|
type(type, charset) {
|
|
2678
2770
|
type = charset ? `${type}; charset=${charset}` : type;
|
|
2679
|
-
this.header("Content-Type",
|
|
2771
|
+
this.header("Content-Type", default3.contentType(type));
|
|
2680
2772
|
return this;
|
|
2681
2773
|
}
|
|
2682
2774
|
/**
|
|
@@ -2963,7 +3055,7 @@ var Response = class extends Macroable6 {
|
|
|
2963
3055
|
return;
|
|
2964
3056
|
}
|
|
2965
3057
|
if (this.content) {
|
|
2966
|
-
this.writeBody
|
|
3058
|
+
httpResponseSerializer.traceSync(this.writeBody, void 0, this, ...this.content);
|
|
2967
3059
|
return;
|
|
2968
3060
|
}
|
|
2969
3061
|
if (this.lazyBody.stream) {
|
|
@@ -3274,22 +3366,13 @@ var Response = class extends Macroable6 {
|
|
|
3274
3366
|
|
|
3275
3367
|
// src/router/main.ts
|
|
3276
3368
|
import is3 from "@sindresorhus/is";
|
|
3369
|
+
import lodash2 from "@poppinss/utils/lodash";
|
|
3277
3370
|
import { moduleImporter as moduleImporter3 } from "@adonisjs/fold";
|
|
3278
|
-
import { RuntimeException as
|
|
3371
|
+
import { RuntimeException as RuntimeException5 } from "@poppinss/utils/exception";
|
|
3279
3372
|
|
|
3280
3373
|
// src/router/store.ts
|
|
3281
|
-
import matchit2 from "@poppinss/matchit";
|
|
3282
|
-
import lodash2 from "@poppinss/utils/lodash";
|
|
3283
|
-
import { RuntimeException as RuntimeException4 } from "@poppinss/utils";
|
|
3284
|
-
|
|
3285
|
-
// src/router/parser.ts
|
|
3286
3374
|
import matchit from "@poppinss/matchit";
|
|
3287
|
-
|
|
3288
|
-
const tokens = matchit.parse(pattern, matchers);
|
|
3289
|
-
return tokens;
|
|
3290
|
-
}
|
|
3291
|
-
|
|
3292
|
-
// src/router/store.ts
|
|
3375
|
+
import { RuntimeException as RuntimeException4 } from "@poppinss/utils/exception";
|
|
3293
3376
|
var RoutesStore = class {
|
|
3294
3377
|
/**
|
|
3295
3378
|
* A flag to know if routes for explicit domains
|
|
@@ -3305,7 +3388,7 @@ var RoutesStore = class {
|
|
|
3305
3388
|
*/
|
|
3306
3389
|
#getDomainNode(domain) {
|
|
3307
3390
|
if (!this.tree.domains[domain]) {
|
|
3308
|
-
this.tree.tokens.push(
|
|
3391
|
+
this.tree.tokens.push(parseRoute(domain));
|
|
3309
3392
|
this.tree.domains[domain] = {};
|
|
3310
3393
|
}
|
|
3311
3394
|
return this.tree.domains[domain];
|
|
@@ -3374,14 +3457,10 @@ var RoutesStore = class {
|
|
|
3374
3457
|
if (route.domain !== "root") {
|
|
3375
3458
|
this.usingDomains = true;
|
|
3376
3459
|
}
|
|
3377
|
-
const
|
|
3378
|
-
|
|
3379
|
-
{ meta: {} },
|
|
3380
|
-
lodash2.pick(route, ["pattern", "handler", "meta", "middleware", "name", "execute"])
|
|
3381
|
-
);
|
|
3382
|
-
routeNode.meta.params = this.#collectRouteParams(routeNode, tokens);
|
|
3460
|
+
const routeNode = { ...route };
|
|
3461
|
+
routeNode.meta.params = this.#collectRouteParams(routeNode, route.tokens);
|
|
3383
3462
|
route.methods.forEach((method) => {
|
|
3384
|
-
this.#registerRoute(route.domain, method, tokens, routeNode);
|
|
3463
|
+
this.#registerRoute(route.domain, method, route.tokens, routeNode);
|
|
3385
3464
|
});
|
|
3386
3465
|
return this;
|
|
3387
3466
|
}
|
|
@@ -3394,7 +3473,7 @@ var RoutesStore = class {
|
|
|
3394
3473
|
* qualified runtime domain. You must call `matchDomain` first to fetch
|
|
3395
3474
|
* the pattern for qualified domain
|
|
3396
3475
|
*/
|
|
3397
|
-
match(url, method, domain) {
|
|
3476
|
+
match(url, method, shouldDecodeParam, domain) {
|
|
3398
3477
|
const domainName = domain?.tokens[0]?.old || "root";
|
|
3399
3478
|
const matchedDomain = this.tree.domains[domainName];
|
|
3400
3479
|
if (!matchedDomain) {
|
|
@@ -3404,7 +3483,7 @@ var RoutesStore = class {
|
|
|
3404
3483
|
if (!matchedMethod) {
|
|
3405
3484
|
return null;
|
|
3406
3485
|
}
|
|
3407
|
-
const matchedRoute =
|
|
3486
|
+
const matchedRoute = matchit.match(url, matchedMethod.tokens);
|
|
3408
3487
|
if (!matchedRoute.length) {
|
|
3409
3488
|
return null;
|
|
3410
3489
|
}
|
|
@@ -3412,8 +3491,8 @@ var RoutesStore = class {
|
|
|
3412
3491
|
return {
|
|
3413
3492
|
route,
|
|
3414
3493
|
routeKey: matchedMethod.routeKeys[route.pattern],
|
|
3415
|
-
params:
|
|
3416
|
-
subdomains: domain?.hostname ?
|
|
3494
|
+
params: matchit.exec(url, matchedRoute, shouldDecodeParam),
|
|
3495
|
+
subdomains: domain?.hostname ? matchit.exec(domain.hostname, domain.tokens) : {}
|
|
3417
3496
|
};
|
|
3418
3497
|
}
|
|
3419
3498
|
/**
|
|
@@ -3423,120 +3502,149 @@ var RoutesStore = class {
|
|
|
3423
3502
|
if (!hostname || !this.usingDomains) {
|
|
3424
3503
|
return [];
|
|
3425
3504
|
}
|
|
3426
|
-
return
|
|
3505
|
+
return matchit.match(hostname, this.tree.tokens);
|
|
3427
3506
|
}
|
|
3428
3507
|
};
|
|
3429
3508
|
|
|
3430
|
-
// src/router
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
// src/router/lookup_store/url_builder.ts
|
|
3434
|
-
import { RuntimeException as RuntimeException5 } from "@poppinss/utils";
|
|
3435
|
-
var UrlBuilder = class {
|
|
3509
|
+
// src/client/router.ts
|
|
3510
|
+
var RouterClient = class {
|
|
3436
3511
|
/**
|
|
3437
|
-
*
|
|
3512
|
+
* List of route references kept for lookup.
|
|
3438
3513
|
*/
|
|
3439
|
-
|
|
3514
|
+
routes;
|
|
3440
3515
|
/**
|
|
3441
|
-
* The
|
|
3516
|
+
* The lookup strategies to follow when generating URL builder
|
|
3517
|
+
* types and client
|
|
3442
3518
|
*/
|
|
3443
|
-
|
|
3519
|
+
lookupStrategies = ["name", "pattern"];
|
|
3520
|
+
constructor(routes) {
|
|
3521
|
+
this.routes = routes ?? {};
|
|
3522
|
+
}
|
|
3444
3523
|
/**
|
|
3445
|
-
*
|
|
3524
|
+
* Register route JSON payload
|
|
3446
3525
|
*/
|
|
3447
|
-
|
|
3526
|
+
register(route) {
|
|
3527
|
+
this.routes[route.domain] = this.routes[route.domain] || [];
|
|
3528
|
+
this.routes[route.domain].push(route);
|
|
3529
|
+
}
|
|
3448
3530
|
/**
|
|
3449
|
-
*
|
|
3450
|
-
*
|
|
3531
|
+
* Define the lookup strategies to follow when generating URL builder
|
|
3532
|
+
* types and client.
|
|
3451
3533
|
*/
|
|
3452
|
-
|
|
3534
|
+
updateLookupStrategies(strategies) {
|
|
3535
|
+
this.lookupStrategies = strategies;
|
|
3536
|
+
return this;
|
|
3537
|
+
}
|
|
3453
3538
|
/**
|
|
3454
|
-
*
|
|
3455
|
-
|
|
3456
|
-
|
|
3539
|
+
* Finds a route by its identifier. The identifier can be the
|
|
3540
|
+
* route name, controller.method name or the route pattern
|
|
3541
|
+
* itself.
|
|
3542
|
+
*
|
|
3543
|
+
* When "followLookupStrategy" is enabled, the lookup will be performed
|
|
3544
|
+
* on the basis of the lookup strategy enabled via the "lookupStrategies"
|
|
3545
|
+
* method. The default lookupStrategy is "name" and "pattern".
|
|
3546
|
+
*/
|
|
3547
|
+
find(routeIdentifier, domain, method, followLookupStrategy) {
|
|
3548
|
+
if (!domain) {
|
|
3549
|
+
let route = null;
|
|
3550
|
+
for (const routeDomain of Object.keys(this.routes)) {
|
|
3551
|
+
route = this.find(routeIdentifier, routeDomain, method, followLookupStrategy);
|
|
3552
|
+
if (route) {
|
|
3553
|
+
break;
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
return route;
|
|
3557
|
+
}
|
|
3558
|
+
const routes = this.routes[domain];
|
|
3559
|
+
if (!routes) {
|
|
3560
|
+
return null;
|
|
3561
|
+
}
|
|
3562
|
+
const lookupByName = !followLookupStrategy || this.lookupStrategies.includes("name");
|
|
3563
|
+
const lookupByPattern = !followLookupStrategy || this.lookupStrategies.includes("pattern");
|
|
3564
|
+
const lookupByController = !followLookupStrategy || this.lookupStrategies.includes("controller");
|
|
3565
|
+
return routes.find((route) => {
|
|
3566
|
+
if (method && !route.methods.includes(method)) {
|
|
3567
|
+
return false;
|
|
3568
|
+
}
|
|
3569
|
+
if (route.name === routeIdentifier && lookupByName || route.pattern === routeIdentifier && lookupByPattern) {
|
|
3570
|
+
return true;
|
|
3571
|
+
}
|
|
3572
|
+
if (typeof route.handler === "function" || !lookupByController) {
|
|
3573
|
+
return false;
|
|
3574
|
+
}
|
|
3575
|
+
return route.handler.reference === routeIdentifier;
|
|
3576
|
+
}) || null;
|
|
3577
|
+
}
|
|
3457
3578
|
/**
|
|
3458
|
-
*
|
|
3579
|
+
* Finds a route by its identifier. The identifier can be the
|
|
3580
|
+
* route name, controller.method name or the route pattern
|
|
3581
|
+
* itself.
|
|
3582
|
+
*
|
|
3583
|
+
* An error is raised when unable to find the route.
|
|
3584
|
+
*
|
|
3585
|
+
* When "followLookupStrategy" is enabled, the lookup will be performed
|
|
3586
|
+
* on the basis of the lookup strategy enabled via the "lookupStrategies"
|
|
3587
|
+
* method. The default lookupStrategy is "name" and "pattern".
|
|
3459
3588
|
*/
|
|
3460
|
-
|
|
3589
|
+
findOrFail(routeIdentifier, domain, method, followLookupStrategy) {
|
|
3590
|
+
const route = this.find(routeIdentifier, domain, method, followLookupStrategy);
|
|
3591
|
+
if (!route) {
|
|
3592
|
+
throw new Error(`Cannot lookup route "${routeIdentifier}"`);
|
|
3593
|
+
}
|
|
3594
|
+
return route;
|
|
3595
|
+
}
|
|
3461
3596
|
/**
|
|
3462
|
-
*
|
|
3597
|
+
* Check if a route exists. The identifier can be the
|
|
3598
|
+
* route name, controller.method name or the route pattern
|
|
3599
|
+
* itself.
|
|
3600
|
+
*
|
|
3601
|
+
* When "followLookupStrategy" is enabled, the lookup will be performed
|
|
3602
|
+
* on the basis of the lookup strategy enabled via the "lookupStrategies"
|
|
3603
|
+
* method. The default lookupStrategy is "name" and "pattern".
|
|
3463
3604
|
*/
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
this.#qsParser = qsParser;
|
|
3467
|
-
this.#encryption = encryption;
|
|
3468
|
-
this.#routeFinder = routeFinder;
|
|
3605
|
+
has(routeIdentifier, domain, method, followLookupStrategy) {
|
|
3606
|
+
return !!this.find(routeIdentifier, domain, method, followLookupStrategy);
|
|
3469
3607
|
}
|
|
3470
3608
|
/**
|
|
3471
|
-
*
|
|
3472
|
-
* has length of zero.
|
|
3609
|
+
* Returns a list of routes grouped by their domain names
|
|
3473
3610
|
*/
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
throw new RuntimeException5(
|
|
3477
|
-
`Cannot make URL for "${pattern}" route. Invalid value provided for wildcard param`
|
|
3478
|
-
);
|
|
3479
|
-
}
|
|
3611
|
+
toJSON() {
|
|
3612
|
+
return this.routes;
|
|
3480
3613
|
}
|
|
3481
|
-
|
|
3482
|
-
|
|
3614
|
+
};
|
|
3615
|
+
|
|
3616
|
+
// src/router/legacy/url_builder.ts
|
|
3617
|
+
var UrlBuilder = class {
|
|
3618
|
+
/**
|
|
3619
|
+
* The parameters to apply on the route
|
|
3483
3620
|
*/
|
|
3484
|
-
#
|
|
3485
|
-
if (value === void 0 || value === null) {
|
|
3486
|
-
throw new RuntimeException5(
|
|
3487
|
-
`Cannot make URL for "${pattern}" route. Missing value for "${param}" param`
|
|
3488
|
-
);
|
|
3489
|
-
}
|
|
3490
|
-
}
|
|
3621
|
+
#params = {};
|
|
3491
3622
|
/**
|
|
3492
|
-
*
|
|
3623
|
+
* Query string to append to the route
|
|
3493
3624
|
*/
|
|
3494
|
-
#
|
|
3495
|
-
const uriSegments = [];
|
|
3496
|
-
const paramsArray = Array.isArray(this.#params) ? this.#params : null;
|
|
3497
|
-
const paramsObject = !Array.isArray(this.#params) ? this.#params : {};
|
|
3498
|
-
let paramsIndex = 0;
|
|
3499
|
-
const tokens = parseRoutePattern(pattern);
|
|
3500
|
-
for (const token of tokens) {
|
|
3501
|
-
if (token.type === 0) {
|
|
3502
|
-
uriSegments.push(token.val === "/" ? "" : `${token.val}${token.end}`);
|
|
3503
|
-
} else if (token.type === 2) {
|
|
3504
|
-
const values = paramsArray ? paramsArray.slice(paramsIndex) : paramsObject["*"];
|
|
3505
|
-
this.#ensureHasWildCardValues(pattern, values);
|
|
3506
|
-
uriSegments.push(`${values.join("/")}${token.end}`);
|
|
3507
|
-
break;
|
|
3508
|
-
} else {
|
|
3509
|
-
const paramName = token.val;
|
|
3510
|
-
const value = paramsArray ? paramsArray[paramsIndex] : paramsObject[paramName];
|
|
3511
|
-
if (token.type === 1) {
|
|
3512
|
-
this.#ensureHasParamValue(pattern, paramName, value);
|
|
3513
|
-
}
|
|
3514
|
-
paramsIndex++;
|
|
3515
|
-
if (value !== void 0 && value !== null) {
|
|
3516
|
-
uriSegments.push(`${value}${token.end}`);
|
|
3517
|
-
}
|
|
3518
|
-
}
|
|
3519
|
-
}
|
|
3520
|
-
return `/${uriSegments.join("/")}`;
|
|
3521
|
-
}
|
|
3625
|
+
#qs = {};
|
|
3522
3626
|
/**
|
|
3523
|
-
*
|
|
3627
|
+
* Should we perform the route lookup or just build the
|
|
3628
|
+
* given pattern as it is.
|
|
3524
3629
|
*/
|
|
3525
|
-
#
|
|
3526
|
-
if (qs) {
|
|
3527
|
-
const queryString = this.#qsParser.stringify(qs);
|
|
3528
|
-
url = queryString ? `${url}?${queryString}` : url;
|
|
3529
|
-
}
|
|
3530
|
-
return url;
|
|
3531
|
-
}
|
|
3630
|
+
#shouldPerformLookup = true;
|
|
3532
3631
|
/**
|
|
3533
|
-
*
|
|
3632
|
+
* BaseURL to append to the constructored URL
|
|
3534
3633
|
*/
|
|
3535
|
-
#
|
|
3536
|
-
|
|
3634
|
+
#baseUrl;
|
|
3635
|
+
/**
|
|
3636
|
+
* Route finder for finding route pattern
|
|
3637
|
+
*/
|
|
3638
|
+
#router;
|
|
3639
|
+
#domain;
|
|
3640
|
+
constructor(router, domain) {
|
|
3641
|
+
this.#router = router;
|
|
3642
|
+
this.#domain = domain;
|
|
3537
3643
|
}
|
|
3538
3644
|
/**
|
|
3539
3645
|
* Prefix a custom base URL to the final URI
|
|
3646
|
+
* @deprecated
|
|
3647
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
3540
3648
|
*/
|
|
3541
3649
|
prefixUrl(url) {
|
|
3542
3650
|
this.#baseUrl = url;
|
|
@@ -3545,6 +3653,8 @@ var UrlBuilder = class {
|
|
|
3545
3653
|
/**
|
|
3546
3654
|
* Disable route lookup. Calling this method considers
|
|
3547
3655
|
* the "identifier" as the route pattern
|
|
3656
|
+
* @deprecated
|
|
3657
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
3548
3658
|
*/
|
|
3549
3659
|
disableRouteLookup() {
|
|
3550
3660
|
this.#shouldPerformLookup = false;
|
|
@@ -3552,6 +3662,8 @@ var UrlBuilder = class {
|
|
|
3552
3662
|
}
|
|
3553
3663
|
/**
|
|
3554
3664
|
* Append query string to the final URI
|
|
3665
|
+
* @deprecated
|
|
3666
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
3555
3667
|
*/
|
|
3556
3668
|
qs(queryString) {
|
|
3557
3669
|
if (!queryString) {
|
|
@@ -3562,6 +3674,8 @@ var UrlBuilder = class {
|
|
|
3562
3674
|
}
|
|
3563
3675
|
/**
|
|
3564
3676
|
* Specify params to apply to the route pattern
|
|
3677
|
+
* @deprecated
|
|
3678
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
3565
3679
|
*/
|
|
3566
3680
|
params(params) {
|
|
3567
3681
|
if (!params) {
|
|
@@ -3574,174 +3688,41 @@ var UrlBuilder = class {
|
|
|
3574
3688
|
* Generate URL for the given route identifier. The identifier can be the
|
|
3575
3689
|
* route name, controller.method name or the route pattern
|
|
3576
3690
|
* itself.
|
|
3691
|
+
*
|
|
3692
|
+
* @deprecated
|
|
3693
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
3577
3694
|
*/
|
|
3578
3695
|
make(identifier) {
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
}
|
|
3586
|
-
return this.#suffixQueryString(this.#prefixBaseUrl(url), this.#qs);
|
|
3696
|
+
return this.#router.makeUrl(identifier, this.#params, {
|
|
3697
|
+
prefixUrl: this.#baseUrl,
|
|
3698
|
+
disableRouteLookup: !this.#shouldPerformLookup,
|
|
3699
|
+
domain: this.#domain,
|
|
3700
|
+
qs: this.#qs
|
|
3701
|
+
});
|
|
3587
3702
|
}
|
|
3588
3703
|
/**
|
|
3589
3704
|
* Generate a signed URL for the given route identifier. The identifier can be the
|
|
3590
3705
|
* route name, controller.method name or the route pattern
|
|
3591
3706
|
* itself.
|
|
3592
|
-
*/
|
|
3593
|
-
makeSigned(identifier, options) {
|
|
3594
|
-
let url;
|
|
3595
|
-
if (this.#shouldPerformLookup) {
|
|
3596
|
-
const route = this.#routeFinder.findOrFail(identifier);
|
|
3597
|
-
url = this.#processPattern(route.pattern);
|
|
3598
|
-
} else {
|
|
3599
|
-
url = this.#processPattern(identifier);
|
|
3600
|
-
}
|
|
3601
|
-
const signature = this.#encryption.verifier.sign(
|
|
3602
|
-
this.#suffixQueryString(url, this.#qs),
|
|
3603
|
-
options?.expiresIn,
|
|
3604
|
-
options?.purpose
|
|
3605
|
-
);
|
|
3606
|
-
const qs = Object.assign({}, this.#qs, { signature });
|
|
3607
|
-
return this.#suffixQueryString(this.#prefixBaseUrl(url), qs);
|
|
3608
|
-
}
|
|
3609
|
-
};
|
|
3610
|
-
|
|
3611
|
-
// src/router/lookup_store/route_finder.ts
|
|
3612
|
-
var RouteFinder = class {
|
|
3613
|
-
#routes = [];
|
|
3614
|
-
register(route) {
|
|
3615
|
-
this.#routes.push(route);
|
|
3616
|
-
}
|
|
3617
|
-
/**
|
|
3618
|
-
* Find a route by indentifier
|
|
3619
|
-
*/
|
|
3620
|
-
find(routeIdentifier) {
|
|
3621
|
-
return this.#routes.find(({ name, pattern, handler }) => {
|
|
3622
|
-
if (name === routeIdentifier || pattern === routeIdentifier) {
|
|
3623
|
-
return true;
|
|
3624
|
-
}
|
|
3625
|
-
if (typeof handler === "function") {
|
|
3626
|
-
return false;
|
|
3627
|
-
}
|
|
3628
|
-
return handler.reference === routeIdentifier;
|
|
3629
|
-
}) || null;
|
|
3630
|
-
}
|
|
3631
|
-
/**
|
|
3632
|
-
* Find a route by indentifier or fail
|
|
3633
|
-
*/
|
|
3634
|
-
findOrFail(routeIdentifier) {
|
|
3635
|
-
const route = this.find(routeIdentifier);
|
|
3636
|
-
if (!route) {
|
|
3637
|
-
throw new E_CANNOT_LOOKUP_ROUTE([routeIdentifier]);
|
|
3638
|
-
}
|
|
3639
|
-
return route;
|
|
3640
|
-
}
|
|
3641
|
-
/**
|
|
3642
|
-
* Find if a route exists
|
|
3643
|
-
*/
|
|
3644
|
-
has(routeIdentifier) {
|
|
3645
|
-
return !!this.find(routeIdentifier);
|
|
3646
|
-
}
|
|
3647
|
-
/**
|
|
3648
|
-
* Returns an array of registered routes
|
|
3649
|
-
*/
|
|
3650
|
-
toJSON() {
|
|
3651
|
-
return this.#routes;
|
|
3652
|
-
}
|
|
3653
|
-
};
|
|
3654
|
-
|
|
3655
|
-
// src/router/lookup_store/main.ts
|
|
3656
|
-
var LookupStore = class extends Macroable7 {
|
|
3657
|
-
/**
|
|
3658
|
-
* List of route finders grouped by domains
|
|
3659
|
-
*/
|
|
3660
|
-
#routes = {};
|
|
3661
|
-
/**
|
|
3662
|
-
* Encryption for making URLs
|
|
3663
|
-
*/
|
|
3664
|
-
#encryption;
|
|
3665
|
-
/**
|
|
3666
|
-
* Query string parser for making URLs
|
|
3667
|
-
*/
|
|
3668
|
-
#qsParser;
|
|
3669
|
-
constructor(encryption, qsParser) {
|
|
3670
|
-
super();
|
|
3671
|
-
this.#encryption = encryption;
|
|
3672
|
-
this.#qsParser = qsParser;
|
|
3673
|
-
}
|
|
3674
|
-
/**
|
|
3675
|
-
* Register route JSON payload
|
|
3676
|
-
*/
|
|
3677
|
-
register(route) {
|
|
3678
|
-
this.#routes[route.domain] = this.#routes[route.domain] || new RouteFinder();
|
|
3679
|
-
this.#routes[route.domain].register(route);
|
|
3680
|
-
}
|
|
3681
|
-
/**
|
|
3682
|
-
* Returns an instance of the URL builder for making
|
|
3683
|
-
* route URIs
|
|
3684
|
-
*/
|
|
3685
|
-
builder() {
|
|
3686
|
-
return this.builderForDomain("root");
|
|
3687
|
-
}
|
|
3688
|
-
/**
|
|
3689
|
-
* Returns an instance of the URL builder for a specific
|
|
3690
|
-
* domain.
|
|
3691
|
-
*/
|
|
3692
|
-
builderForDomain(domain) {
|
|
3693
|
-
const finder = this.#routes[domain];
|
|
3694
|
-
return new UrlBuilder(this.#encryption, finder || new RouteFinder(), this.#qsParser);
|
|
3695
|
-
}
|
|
3696
|
-
/**
|
|
3697
|
-
* Finds a route by its identifier. The identifier can be the
|
|
3698
|
-
* route name, controller.method name or the route pattern
|
|
3699
|
-
* itself.
|
|
3700
|
-
*/
|
|
3701
|
-
find(routeIdentifier, domain) {
|
|
3702
|
-
const finder = this.#routes[domain || "root"];
|
|
3703
|
-
if (!finder) {
|
|
3704
|
-
return null;
|
|
3705
|
-
}
|
|
3706
|
-
return finder.find(routeIdentifier);
|
|
3707
|
-
}
|
|
3708
|
-
/**
|
|
3709
|
-
* Finds a route by its identifier. The identifier can be the
|
|
3710
|
-
* route name, controller.method name or the route pattern
|
|
3711
|
-
* itself.
|
|
3712
3707
|
*
|
|
3713
|
-
*
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
const finder = this.#routes[domain || "root"];
|
|
3717
|
-
if (!finder) {
|
|
3718
|
-
throw new E_CANNOT_LOOKUP_ROUTE([routeIdentifier]);
|
|
3719
|
-
}
|
|
3720
|
-
return finder.findOrFail(routeIdentifier);
|
|
3721
|
-
}
|
|
3722
|
-
/**
|
|
3723
|
-
* Check if a route exists. The identifier can be the
|
|
3724
|
-
* route name, controller.method name or the route pattern
|
|
3725
|
-
* itself.
|
|
3708
|
+
* @deprecated
|
|
3709
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
3710
|
+
*
|
|
3726
3711
|
*/
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
return Object.keys(this.#routes).reduce((result, domain) => {
|
|
3736
|
-
result[domain] = this.#routes[domain].toJSON();
|
|
3737
|
-
return result;
|
|
3738
|
-
}, {});
|
|
3712
|
+
makeSigned(identifier, options) {
|
|
3713
|
+
return this.#router.makeSignedUrl(identifier, this.#params, {
|
|
3714
|
+
prefixUrl: this.#baseUrl,
|
|
3715
|
+
disableRouteLookup: !this.#shouldPerformLookup,
|
|
3716
|
+
domain: this.#domain,
|
|
3717
|
+
qs: this.#qs,
|
|
3718
|
+
...options
|
|
3719
|
+
});
|
|
3739
3720
|
}
|
|
3740
3721
|
};
|
|
3741
3722
|
|
|
3742
3723
|
// src/router/matchers.ts
|
|
3743
|
-
import
|
|
3744
|
-
var RouteMatchers = class extends
|
|
3724
|
+
import Macroable7 from "@poppinss/macroable";
|
|
3725
|
+
var RouteMatchers = class extends Macroable7 {
|
|
3745
3726
|
/**
|
|
3746
3727
|
* Enforce value to be a number and also casts it to number data
|
|
3747
3728
|
* type
|
|
@@ -3774,6 +3755,7 @@ function middlewareReferenceBuilder(name, middleware) {
|
|
|
3774
3755
|
return {
|
|
3775
3756
|
...handler,
|
|
3776
3757
|
name,
|
|
3758
|
+
reference: middleware,
|
|
3777
3759
|
args: args[0]
|
|
3778
3760
|
};
|
|
3779
3761
|
};
|
|
@@ -3788,8 +3770,225 @@ function defineNamedMiddleware(collection) {
|
|
|
3788
3770
|
);
|
|
3789
3771
|
}
|
|
3790
3772
|
|
|
3773
|
+
// src/client/url_builder.ts
|
|
3774
|
+
function createURL(identifier, tokens, searchParamsStringifier, params, options) {
|
|
3775
|
+
const uriSegments = [];
|
|
3776
|
+
const paramsArray = Array.isArray(params) ? params : null;
|
|
3777
|
+
const paramsObject = !Array.isArray(params) ? params ?? {} : {};
|
|
3778
|
+
let paramsIndex = 0;
|
|
3779
|
+
for (const token of tokens) {
|
|
3780
|
+
if (token.type === 0) {
|
|
3781
|
+
uriSegments.push(token.val === "/" ? "" : `${token.val}${token.end}`);
|
|
3782
|
+
continue;
|
|
3783
|
+
}
|
|
3784
|
+
if (token.type === 2) {
|
|
3785
|
+
const values = paramsArray ? paramsArray.slice(paramsIndex) : paramsObject["*"];
|
|
3786
|
+
if (!Array.isArray(values) || !values.length) {
|
|
3787
|
+
throw new Error(
|
|
3788
|
+
`Cannot make URL for "${identifier}". Invalid value provided for the wildcard param`
|
|
3789
|
+
);
|
|
3790
|
+
}
|
|
3791
|
+
uriSegments.push(`${values.join("/")}${token.end}`);
|
|
3792
|
+
break;
|
|
3793
|
+
}
|
|
3794
|
+
const paramName = token.val;
|
|
3795
|
+
const value = paramsArray ? paramsArray[paramsIndex] : paramsObject[paramName];
|
|
3796
|
+
const isDefined = value !== void 0 && value !== null;
|
|
3797
|
+
if (token.type === 1 && !isDefined) {
|
|
3798
|
+
throw new Error(
|
|
3799
|
+
`Cannot make URL for "${identifier}". Missing value for the "${paramName}" param`
|
|
3800
|
+
);
|
|
3801
|
+
}
|
|
3802
|
+
if (isDefined) {
|
|
3803
|
+
uriSegments.push(`${value}${token.end}`);
|
|
3804
|
+
}
|
|
3805
|
+
paramsIndex++;
|
|
3806
|
+
}
|
|
3807
|
+
let URI = `/${uriSegments.join("/")}`;
|
|
3808
|
+
if (options?.prefixUrl) {
|
|
3809
|
+
URI = `${options?.prefixUrl.replace(/\/$/, "")}${URI}`;
|
|
3810
|
+
}
|
|
3811
|
+
if (options?.qs) {
|
|
3812
|
+
const queryString = searchParamsStringifier(options?.qs);
|
|
3813
|
+
URI = queryString ? `${URI}?${queryString}` : URI;
|
|
3814
|
+
}
|
|
3815
|
+
return URI;
|
|
3816
|
+
}
|
|
3817
|
+
function createUrlBuilder(router, searchParamsStringifier) {
|
|
3818
|
+
let domainsList;
|
|
3819
|
+
function createUrlForRoute(identifier, params, options, method) {
|
|
3820
|
+
if (!domainsList) {
|
|
3821
|
+
domainsList = Object.keys(router.toJSON()).filter((domain2) => domain2 !== "root");
|
|
3822
|
+
}
|
|
3823
|
+
const domain = domainsList.find((name) => identifier.startsWith(`${name}@`));
|
|
3824
|
+
const routeIdentifier = domain ? identifier.replace(new RegExp(`^${domain}@`), "") : identifier;
|
|
3825
|
+
const route = router.findOrFail(routeIdentifier, domain, method, true);
|
|
3826
|
+
return createURL(
|
|
3827
|
+
route.name ?? route.pattern,
|
|
3828
|
+
route.tokens,
|
|
3829
|
+
searchParamsStringifier,
|
|
3830
|
+
params,
|
|
3831
|
+
options
|
|
3832
|
+
);
|
|
3833
|
+
}
|
|
3834
|
+
const urlFor = function route(...[identifier, params, options]) {
|
|
3835
|
+
return createUrlForRoute(identifier, params, options);
|
|
3836
|
+
};
|
|
3837
|
+
urlFor.get = function urlForMethodGet(...[identifier, params, options]) {
|
|
3838
|
+
return {
|
|
3839
|
+
url: createUrlForRoute(identifier, params, options, "GET"),
|
|
3840
|
+
method: "get",
|
|
3841
|
+
toString() {
|
|
3842
|
+
return this.url;
|
|
3843
|
+
}
|
|
3844
|
+
};
|
|
3845
|
+
};
|
|
3846
|
+
urlFor.post = function urlForMethodPost(...[identifier, params, options]) {
|
|
3847
|
+
return {
|
|
3848
|
+
url: createUrlForRoute(identifier, params, options, "POST"),
|
|
3849
|
+
method: "post",
|
|
3850
|
+
toString() {
|
|
3851
|
+
return this.url;
|
|
3852
|
+
}
|
|
3853
|
+
};
|
|
3854
|
+
};
|
|
3855
|
+
urlFor.put = function urlForMethodPut(...[identifier, params, options]) {
|
|
3856
|
+
return {
|
|
3857
|
+
url: createUrlForRoute(identifier, params, options, "PUT"),
|
|
3858
|
+
method: "put",
|
|
3859
|
+
toString() {
|
|
3860
|
+
return this.url;
|
|
3861
|
+
}
|
|
3862
|
+
};
|
|
3863
|
+
};
|
|
3864
|
+
urlFor.patch = function urlForMethodPatch(...[identifier, params, options]) {
|
|
3865
|
+
return {
|
|
3866
|
+
url: createUrlForRoute(identifier, params, options, "PATCH"),
|
|
3867
|
+
method: "patch",
|
|
3868
|
+
toString() {
|
|
3869
|
+
return this.url;
|
|
3870
|
+
}
|
|
3871
|
+
};
|
|
3872
|
+
};
|
|
3873
|
+
urlFor.delete = function urlForMethodDelete(...[identifier, params, options]) {
|
|
3874
|
+
return {
|
|
3875
|
+
url: createUrlForRoute(identifier, params, options, "DELETE"),
|
|
3876
|
+
method: "delete",
|
|
3877
|
+
toString() {
|
|
3878
|
+
return this.url;
|
|
3879
|
+
}
|
|
3880
|
+
};
|
|
3881
|
+
};
|
|
3882
|
+
urlFor.method = function urlForCustomMethod(method, ...[identifier, params, options]) {
|
|
3883
|
+
return {
|
|
3884
|
+
url: createUrlForRoute(identifier, params, options, method),
|
|
3885
|
+
method,
|
|
3886
|
+
toString() {
|
|
3887
|
+
return this.url;
|
|
3888
|
+
}
|
|
3889
|
+
};
|
|
3890
|
+
};
|
|
3891
|
+
return urlFor;
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
// src/router/signed_url_builder.ts
|
|
3895
|
+
function createSignedURL(identifier, tokens, searchParamsStringifier, encryption, params, options) {
|
|
3896
|
+
const signature = encryption.verifier.sign(
|
|
3897
|
+
createURL(identifier, tokens, searchParamsStringifier, params, {
|
|
3898
|
+
...options,
|
|
3899
|
+
prefixUrl: void 0
|
|
3900
|
+
}),
|
|
3901
|
+
options?.expiresIn,
|
|
3902
|
+
options?.purpose
|
|
3903
|
+
);
|
|
3904
|
+
return createURL(identifier, tokens, searchParamsStringifier, params, {
|
|
3905
|
+
...options,
|
|
3906
|
+
qs: { ...options?.qs, signature }
|
|
3907
|
+
});
|
|
3908
|
+
}
|
|
3909
|
+
function createSignedUrlBuilder(router, encryption, searchParamsStringifier) {
|
|
3910
|
+
let domainsList;
|
|
3911
|
+
function createSignedUrlForRoute(identifier, params, options, method) {
|
|
3912
|
+
if (!domainsList) {
|
|
3913
|
+
domainsList = Object.keys(router.toJSON()).filter((domain2) => domain2 !== "root");
|
|
3914
|
+
}
|
|
3915
|
+
const domain = domainsList.find((name) => identifier.startsWith(`${name}@`));
|
|
3916
|
+
const routeIdentifier = domain ? identifier.replace(new RegExp(`^${domain}@`), "") : identifier;
|
|
3917
|
+
const route = router.findOrFail(routeIdentifier, domain, method, true);
|
|
3918
|
+
return createSignedURL(
|
|
3919
|
+
route.name ?? route.pattern,
|
|
3920
|
+
route.tokens,
|
|
3921
|
+
searchParamsStringifier,
|
|
3922
|
+
encryption,
|
|
3923
|
+
params,
|
|
3924
|
+
options
|
|
3925
|
+
);
|
|
3926
|
+
}
|
|
3927
|
+
const signedRoute = function route(...[identifier, params, options]) {
|
|
3928
|
+
return createSignedUrlForRoute(identifier, params, options);
|
|
3929
|
+
};
|
|
3930
|
+
signedRoute.get = function routeGet(...[identifier, params, options]) {
|
|
3931
|
+
return {
|
|
3932
|
+
url: createSignedUrlForRoute(identifier, params, options, "GET"),
|
|
3933
|
+
method: "get",
|
|
3934
|
+
toString() {
|
|
3935
|
+
return this.url;
|
|
3936
|
+
}
|
|
3937
|
+
};
|
|
3938
|
+
};
|
|
3939
|
+
signedRoute.post = function routePost(...[identifier, params, options]) {
|
|
3940
|
+
return {
|
|
3941
|
+
url: createSignedUrlForRoute(identifier, params, options, "POST"),
|
|
3942
|
+
method: "post",
|
|
3943
|
+
toString() {
|
|
3944
|
+
return this.url;
|
|
3945
|
+
}
|
|
3946
|
+
};
|
|
3947
|
+
};
|
|
3948
|
+
signedRoute.put = function routePut(...[identifier, params, options]) {
|
|
3949
|
+
return {
|
|
3950
|
+
url: createSignedUrlForRoute(identifier, params, options, "PUT"),
|
|
3951
|
+
method: "put",
|
|
3952
|
+
toString() {
|
|
3953
|
+
return this.url;
|
|
3954
|
+
}
|
|
3955
|
+
};
|
|
3956
|
+
};
|
|
3957
|
+
signedRoute.patch = function routePatch(...[identifier, params, options]) {
|
|
3958
|
+
return {
|
|
3959
|
+
url: createSignedUrlForRoute(identifier, params, options, "PATCH"),
|
|
3960
|
+
method: "patch",
|
|
3961
|
+
toString() {
|
|
3962
|
+
return this.url;
|
|
3963
|
+
}
|
|
3964
|
+
};
|
|
3965
|
+
};
|
|
3966
|
+
signedRoute.delete = function routeDelete(...[identifier, params, options]) {
|
|
3967
|
+
return {
|
|
3968
|
+
url: createSignedUrlForRoute(identifier, params, options, "DELETE"),
|
|
3969
|
+
method: "delete",
|
|
3970
|
+
toString() {
|
|
3971
|
+
return this.url;
|
|
3972
|
+
}
|
|
3973
|
+
};
|
|
3974
|
+
};
|
|
3975
|
+
signedRoute.method = function routeGet(method, ...[identifier, params, options]) {
|
|
3976
|
+
return {
|
|
3977
|
+
url: createSignedUrlForRoute(identifier, params, options, method),
|
|
3978
|
+
method,
|
|
3979
|
+
toString() {
|
|
3980
|
+
return this.url;
|
|
3981
|
+
}
|
|
3982
|
+
};
|
|
3983
|
+
};
|
|
3984
|
+
return signedRoute;
|
|
3985
|
+
}
|
|
3986
|
+
|
|
3791
3987
|
// src/router/main.ts
|
|
3792
|
-
var Router = class extends
|
|
3988
|
+
var Router = class extends RouterClient {
|
|
3989
|
+
/**
|
|
3990
|
+
* Flag to avoid re-comitting routes to the store
|
|
3991
|
+
*/
|
|
3793
3992
|
#commited = false;
|
|
3794
3993
|
/**
|
|
3795
3994
|
* Application is needed to resolve string based controller expressions
|
|
@@ -3799,6 +3998,10 @@ var Router = class extends LookupStore {
|
|
|
3799
3998
|
* Store with tokenized routes
|
|
3800
3999
|
*/
|
|
3801
4000
|
#store = new RoutesStore();
|
|
4001
|
+
/**
|
|
4002
|
+
* Encryption for making signed URLs
|
|
4003
|
+
*/
|
|
4004
|
+
#encryption;
|
|
3802
4005
|
/**
|
|
3803
4006
|
* Global matchers to test route params against regular expressions.
|
|
3804
4007
|
*/
|
|
@@ -3813,10 +4016,10 @@ var Router = class extends LookupStore {
|
|
|
3813
4016
|
*/
|
|
3814
4017
|
#openedGroups = [];
|
|
3815
4018
|
/**
|
|
3816
|
-
* Collection of routes
|
|
3817
|
-
*
|
|
4019
|
+
* Collection of routes to be committed with the store, including
|
|
4020
|
+
* route resource and route group.
|
|
3818
4021
|
*/
|
|
3819
|
-
|
|
4022
|
+
#routesToBeCommitted = [];
|
|
3820
4023
|
/**
|
|
3821
4024
|
* A flag to know if routes for explicit domains have been registered.
|
|
3822
4025
|
* The boolean is computed after calling the "commit" method.
|
|
@@ -3834,9 +4037,27 @@ var Router = class extends LookupStore {
|
|
|
3834
4037
|
get commited() {
|
|
3835
4038
|
return this.#commited;
|
|
3836
4039
|
}
|
|
4040
|
+
/**
|
|
4041
|
+
* Query string parser for making URLs
|
|
4042
|
+
*/
|
|
4043
|
+
qs;
|
|
4044
|
+
/**
|
|
4045
|
+
* The URLBuilder offers a type-safe API for creating URL for pre-registered
|
|
4046
|
+
* routes or the route patterns.
|
|
4047
|
+
*
|
|
4048
|
+
* We recommend using the URLBuilder over the "makeUrl" and "makeSignedUrl"
|
|
4049
|
+
* methods.
|
|
4050
|
+
*/
|
|
4051
|
+
urlBuilder;
|
|
3837
4052
|
constructor(app, encryption, qsParser) {
|
|
3838
|
-
super(
|
|
4053
|
+
super();
|
|
3839
4054
|
this.#app = app;
|
|
4055
|
+
this.#encryption = encryption;
|
|
4056
|
+
this.qs = qsParser;
|
|
4057
|
+
this.urlBuilder = {
|
|
4058
|
+
urlFor: createUrlBuilder(this, this.qs.stringify),
|
|
4059
|
+
signedUrlFor: createSignedUrlBuilder(this, this.#encryption, this.qs.stringify)
|
|
4060
|
+
};
|
|
3840
4061
|
}
|
|
3841
4062
|
/**
|
|
3842
4063
|
* Push a give router entity to the list of routes or the
|
|
@@ -3848,13 +4069,13 @@ var Router = class extends LookupStore {
|
|
|
3848
4069
|
openedGroup.routes.push(entity);
|
|
3849
4070
|
return;
|
|
3850
4071
|
}
|
|
3851
|
-
this.
|
|
4072
|
+
this.#routesToBeCommitted.push(entity);
|
|
3852
4073
|
}
|
|
3853
4074
|
/**
|
|
3854
4075
|
* Parses the route pattern
|
|
3855
4076
|
*/
|
|
3856
4077
|
parsePattern(pattern, matchers) {
|
|
3857
|
-
return
|
|
4078
|
+
return parseRoute(pattern, matchers);
|
|
3858
4079
|
}
|
|
3859
4080
|
/**
|
|
3860
4081
|
* Define an array of middleware to use on all the routes.
|
|
@@ -3863,7 +4084,10 @@ var Router = class extends LookupStore {
|
|
|
3863
4084
|
*/
|
|
3864
4085
|
use(middleware) {
|
|
3865
4086
|
middleware.forEach(
|
|
3866
|
-
(one) => this.#middleware.push(
|
|
4087
|
+
(one) => this.#middleware.push({
|
|
4088
|
+
reference: one,
|
|
4089
|
+
...moduleImporter3(one, "handle").toHandleMethod()
|
|
4090
|
+
})
|
|
3867
4091
|
);
|
|
3868
4092
|
return this;
|
|
3869
4093
|
}
|
|
@@ -4001,13 +4225,13 @@ var Router = class extends LookupStore {
|
|
|
4001
4225
|
}
|
|
4002
4226
|
debug_default("Committing routes to the routes store");
|
|
4003
4227
|
const routeNamesByDomain = /* @__PURE__ */ new Map();
|
|
4004
|
-
toRoutesJSON(this
|
|
4228
|
+
toRoutesJSON(this.#routesToBeCommitted).forEach((route) => {
|
|
4005
4229
|
if (!routeNamesByDomain.has(route.domain)) {
|
|
4006
4230
|
routeNamesByDomain.set(route.domain, /* @__PURE__ */ new Set());
|
|
4007
4231
|
}
|
|
4008
4232
|
const routeNames = routeNamesByDomain.get(route.domain);
|
|
4009
4233
|
if (route.name && routeNames.has(route.name)) {
|
|
4010
|
-
throw new
|
|
4234
|
+
throw new RuntimeException5(
|
|
4011
4235
|
`Route with duplicate name found. A route with name "${route.name}" already exists`
|
|
4012
4236
|
);
|
|
4013
4237
|
}
|
|
@@ -4019,51 +4243,206 @@ var Router = class extends LookupStore {
|
|
|
4019
4243
|
});
|
|
4020
4244
|
routeNamesByDomain.clear();
|
|
4021
4245
|
this.usingDomains = this.#store.usingDomains;
|
|
4022
|
-
this
|
|
4246
|
+
this.#routesToBeCommitted = [];
|
|
4023
4247
|
this.#globalMatchers = {};
|
|
4024
4248
|
this.#middleware = [];
|
|
4249
|
+
this.#openedGroups = [];
|
|
4025
4250
|
this.#commited = true;
|
|
4026
4251
|
}
|
|
4252
|
+
/**
|
|
4253
|
+
* Generates types for the URL builder. These types must
|
|
4254
|
+
* be written inside a file for the URL builder to
|
|
4255
|
+
* pick them up.
|
|
4256
|
+
*/
|
|
4257
|
+
generateTypes(indentation = 0) {
|
|
4258
|
+
const routesList = {};
|
|
4259
|
+
function trackRoute(route, domain) {
|
|
4260
|
+
let params = [];
|
|
4261
|
+
let paramsTuple = [];
|
|
4262
|
+
let hasRequiredParams = false;
|
|
4263
|
+
for (let token of route.tokens) {
|
|
4264
|
+
if (token.type === 1) {
|
|
4265
|
+
hasRequiredParams = true;
|
|
4266
|
+
params.push(`'${token.val}': string`);
|
|
4267
|
+
paramsTuple.push("string");
|
|
4268
|
+
} else if (token.type === 3) {
|
|
4269
|
+
params.push(`'${token.val}'?: string`);
|
|
4270
|
+
paramsTuple.push("string?");
|
|
4271
|
+
} else if (token.type === 2) {
|
|
4272
|
+
hasRequiredParams = true;
|
|
4273
|
+
params.push(`'*': string[]`);
|
|
4274
|
+
paramsTuple.push("...string[]");
|
|
4275
|
+
break;
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4278
|
+
route.methods.forEach((method) => {
|
|
4279
|
+
routesList["ALL"] = routesList["ALL"] ?? {};
|
|
4280
|
+
routesList[method] = routesList[method] ?? {};
|
|
4281
|
+
const identifiers = [];
|
|
4282
|
+
if (this.lookupStrategies.includes("pattern")) {
|
|
4283
|
+
if (!routesList[method][route.pattern]) {
|
|
4284
|
+
identifiers.push(route.pattern);
|
|
4285
|
+
}
|
|
4286
|
+
}
|
|
4287
|
+
if (this.lookupStrategies.includes("name") && route.name) {
|
|
4288
|
+
identifiers.push(
|
|
4289
|
+
domain && routesList[method][route.name] ? `${domain}@${route.name}` : route.name
|
|
4290
|
+
);
|
|
4291
|
+
}
|
|
4292
|
+
if (this.lookupStrategies.includes("controller") && "reference" in route.handler && typeof route.handler.reference === "string") {
|
|
4293
|
+
identifiers.push(
|
|
4294
|
+
domain && routesList[method][route.handler.reference] ? `${domain}@${route.handler.reference}` : route.handler.reference
|
|
4295
|
+
);
|
|
4296
|
+
}
|
|
4297
|
+
identifiers.forEach((identifier) => {
|
|
4298
|
+
routesList["ALL"][identifier] = {
|
|
4299
|
+
params,
|
|
4300
|
+
paramsTuple,
|
|
4301
|
+
hasRequiredParams
|
|
4302
|
+
};
|
|
4303
|
+
routesList[method][identifier] = {
|
|
4304
|
+
params,
|
|
4305
|
+
paramsTuple,
|
|
4306
|
+
hasRequiredParams
|
|
4307
|
+
};
|
|
4308
|
+
});
|
|
4309
|
+
});
|
|
4310
|
+
}
|
|
4311
|
+
const domains = Object.keys(this.routes).filter((domain) => domain !== "root");
|
|
4312
|
+
this.routes["root"].forEach((route) => trackRoute.bind(this)(route));
|
|
4313
|
+
domains.forEach(
|
|
4314
|
+
(domain) => this.routes[domain].forEach((route) => trackRoute.bind(this)(route, domain))
|
|
4315
|
+
);
|
|
4316
|
+
return Object.keys(routesList).reduce((result, method) => {
|
|
4317
|
+
result.push(`${" ".repeat(indentation)}'${method}': {`);
|
|
4318
|
+
Object.keys(routesList[method]).forEach((identifier) => {
|
|
4319
|
+
const key = `'${identifier}'`;
|
|
4320
|
+
const { paramsTuple, hasRequiredParams, params } = routesList[method][identifier];
|
|
4321
|
+
const dictName = hasRequiredParams ? "params" : "params?";
|
|
4322
|
+
const tupleName = hasRequiredParams ? "paramsTuple" : "paramsTuple?";
|
|
4323
|
+
const dictValue = `{${params.join(",")}}`;
|
|
4324
|
+
const tupleValue = `[${paramsTuple?.join(",")}]`;
|
|
4325
|
+
const value = `{ ${tupleName}: ${tupleValue}, ${dictName}: ${dictValue} }`;
|
|
4326
|
+
result.push(`${" ".repeat(indentation + 2)}${key}: ${value},`);
|
|
4327
|
+
});
|
|
4328
|
+
result.push(`${" ".repeat(indentation)}},`);
|
|
4329
|
+
return result;
|
|
4330
|
+
}, []).join("\n");
|
|
4331
|
+
}
|
|
4332
|
+
generateClient() {
|
|
4333
|
+
const routesForClient = Object.keys(this.routes).reduce(
|
|
4334
|
+
(result, domain) => {
|
|
4335
|
+
const routes = this.routes[domain];
|
|
4336
|
+
result[domain] = routes.map((route) => {
|
|
4337
|
+
const controller = "reference" in route.handler && typeof route.handler.reference === "string" ? route.handler.reference : void 0;
|
|
4338
|
+
return {
|
|
4339
|
+
pattern: route.pattern,
|
|
4340
|
+
name: route.name,
|
|
4341
|
+
handler: {
|
|
4342
|
+
reference: controller
|
|
4343
|
+
},
|
|
4344
|
+
methods: route.methods,
|
|
4345
|
+
domain: route.domain,
|
|
4346
|
+
tokens: route.tokens.map((tokens) => {
|
|
4347
|
+
return lodash2.pick(tokens, ["val", "type", "end"]);
|
|
4348
|
+
})
|
|
4349
|
+
};
|
|
4350
|
+
});
|
|
4351
|
+
return result;
|
|
4352
|
+
},
|
|
4353
|
+
{}
|
|
4354
|
+
);
|
|
4355
|
+
return `import type { RoutesList } from '@adonisjs/core/types/http'
|
|
4356
|
+
import { RouterClient, createUrlBuilder, ClientRouteJSON } from 'adonisjs/core/http/client'
|
|
4357
|
+
|
|
4358
|
+
const routes = ${JSON.stringify(routesForClient)} satisfies { [domain: string]: ClientRouteJSON[] }
|
|
4359
|
+
const router = new RouterClient(routes)
|
|
4360
|
+
export const urlFor = createUrlBuilder<RoutesList>(router, (qs) => {
|
|
4361
|
+
return new URLSearchParams(qs).toString()
|
|
4362
|
+
})`;
|
|
4363
|
+
}
|
|
4027
4364
|
/**
|
|
4028
4365
|
* Find route for a given URL, method and optionally domain
|
|
4029
4366
|
*/
|
|
4030
|
-
match(
|
|
4367
|
+
match(uri, method, shouldDecodeParam, hostname) {
|
|
4031
4368
|
const matchingDomain = this.#store.matchDomain(hostname);
|
|
4032
|
-
return matchingDomain.length ? this.#store.match(
|
|
4369
|
+
return matchingDomain.length ? this.#store.match(uri, method, shouldDecodeParam, {
|
|
4033
4370
|
tokens: matchingDomain,
|
|
4034
4371
|
hostname
|
|
4035
|
-
}) : this.#store.match(
|
|
4372
|
+
}) : this.#store.match(uri, method, shouldDecodeParam);
|
|
4373
|
+
}
|
|
4374
|
+
/**
|
|
4375
|
+
* Create URL builder instance.
|
|
4376
|
+
* @deprecated
|
|
4377
|
+
*
|
|
4378
|
+
* Instead use "@adonisjs/core/services/url_builder" instead
|
|
4379
|
+
*/
|
|
4380
|
+
builder() {
|
|
4381
|
+
return new UrlBuilder(this);
|
|
4382
|
+
}
|
|
4383
|
+
/**
|
|
4384
|
+
* Create URL builder instance for a given domain.
|
|
4385
|
+
* @deprecated
|
|
4386
|
+
*
|
|
4387
|
+
* Instead use "@adonisjs/core/services/url_builder"
|
|
4388
|
+
*/
|
|
4389
|
+
builderForDomain(domain) {
|
|
4390
|
+
return new UrlBuilder(this, domain);
|
|
4036
4391
|
}
|
|
4037
4392
|
/**
|
|
4038
4393
|
* Make URL to a pre-registered route
|
|
4394
|
+
*
|
|
4395
|
+
* @deprecated
|
|
4396
|
+
* Instead use "@adonisjs/core/services/url_builder"
|
|
4039
4397
|
*/
|
|
4040
4398
|
makeUrl(routeIdentifier, params, options) {
|
|
4041
4399
|
const normalizedOptions = Object.assign({}, options);
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4400
|
+
if (options?.disableRouteLookup) {
|
|
4401
|
+
return createURL(
|
|
4402
|
+
routeIdentifier,
|
|
4403
|
+
parseRoute(routeIdentifier),
|
|
4404
|
+
this.qs.stringify,
|
|
4405
|
+
params,
|
|
4406
|
+
options
|
|
4407
|
+
);
|
|
4408
|
+
}
|
|
4409
|
+
const route = this.findOrFail(routeIdentifier, normalizedOptions.domain);
|
|
4410
|
+
return createURL(route.name ?? route.pattern, route.tokens, this.qs.stringify, params, options);
|
|
4048
4411
|
}
|
|
4049
4412
|
/**
|
|
4050
4413
|
* Makes a signed URL to a pre-registered route.
|
|
4414
|
+
*
|
|
4415
|
+
* @deprecated
|
|
4416
|
+
* Instead use "@adonisjs/core/services/url_builder"
|
|
4051
4417
|
*/
|
|
4052
4418
|
makeSignedUrl(routeIdentifier, params, options) {
|
|
4053
4419
|
const normalizedOptions = Object.assign({}, options);
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4420
|
+
if (options?.disableRouteLookup) {
|
|
4421
|
+
return createSignedURL(
|
|
4422
|
+
routeIdentifier,
|
|
4423
|
+
parseRoute(routeIdentifier),
|
|
4424
|
+
this.qs.stringify,
|
|
4425
|
+
this.#encryption,
|
|
4426
|
+
params,
|
|
4427
|
+
options
|
|
4428
|
+
);
|
|
4429
|
+
}
|
|
4430
|
+
const route = this.findOrFail(routeIdentifier, normalizedOptions.domain);
|
|
4431
|
+
return createSignedURL(
|
|
4432
|
+
route.name ?? route.pattern,
|
|
4433
|
+
route.tokens,
|
|
4434
|
+
this.qs.stringify,
|
|
4435
|
+
this.#encryption,
|
|
4436
|
+
params,
|
|
4437
|
+
options
|
|
4438
|
+
);
|
|
4060
4439
|
}
|
|
4061
4440
|
};
|
|
4062
4441
|
|
|
4063
4442
|
// src/http_context/main.ts
|
|
4064
4443
|
import { inspect } from "util";
|
|
4065
|
-
import
|
|
4066
|
-
import { RuntimeException as
|
|
4444
|
+
import Macroable8 from "@poppinss/macroable";
|
|
4445
|
+
import { RuntimeException as RuntimeException6 } from "@poppinss/utils/exception";
|
|
4067
4446
|
|
|
4068
4447
|
// src/http_context/local_storage.ts
|
|
4069
4448
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -4096,7 +4475,7 @@ var asyncLocalStorage = {
|
|
|
4096
4475
|
};
|
|
4097
4476
|
|
|
4098
4477
|
// src/http_context/main.ts
|
|
4099
|
-
var HttpContext = class extends
|
|
4478
|
+
var HttpContext = class extends Macroable8 {
|
|
4100
4479
|
constructor(request, response, logger, containerResolver) {
|
|
4101
4480
|
super();
|
|
4102
4481
|
this.request = request;
|
|
@@ -4129,13 +4508,13 @@ var HttpContext = class extends Macroable9 {
|
|
|
4129
4508
|
*/
|
|
4130
4509
|
static getOrFail() {
|
|
4131
4510
|
if (!this.usingAsyncLocalStorage || !asyncLocalStorage.storage) {
|
|
4132
|
-
throw new
|
|
4511
|
+
throw new RuntimeException6(
|
|
4133
4512
|
'HTTP context is not available. Enable "useAsyncLocalStorage" inside "config/app.ts" file'
|
|
4134
4513
|
);
|
|
4135
4514
|
}
|
|
4136
4515
|
const store = this.get();
|
|
4137
4516
|
if (!store) {
|
|
4138
|
-
throw new
|
|
4517
|
+
throw new RuntimeException6("Http context is not available outside of an HTTP request");
|
|
4139
4518
|
}
|
|
4140
4519
|
return store;
|
|
4141
4520
|
}
|
|
@@ -4181,27 +4560,27 @@ import Middleware2 from "@poppinss/middleware";
|
|
|
4181
4560
|
import { moduleCaller as moduleCaller2, moduleImporter as moduleImporter4 } from "@adonisjs/fold";
|
|
4182
4561
|
|
|
4183
4562
|
// src/qs.ts
|
|
4184
|
-
import { parse as
|
|
4563
|
+
import { parse as parse2, stringify } from "qs";
|
|
4185
4564
|
var Qs = class {
|
|
4186
4565
|
#config;
|
|
4187
4566
|
constructor(config) {
|
|
4188
4567
|
this.#config = config;
|
|
4189
4568
|
}
|
|
4190
|
-
parse(value) {
|
|
4191
|
-
return
|
|
4192
|
-
}
|
|
4193
|
-
stringify(value) {
|
|
4569
|
+
parse = (value) => {
|
|
4570
|
+
return parse2(value, this.#config.parse);
|
|
4571
|
+
};
|
|
4572
|
+
stringify = (value) => {
|
|
4194
4573
|
return stringify(value, this.#config.stringify);
|
|
4195
|
-
}
|
|
4574
|
+
};
|
|
4196
4575
|
};
|
|
4197
4576
|
|
|
4198
|
-
// src/server/factories/
|
|
4199
|
-
function
|
|
4577
|
+
// src/server/factories/route_finder.ts
|
|
4578
|
+
function routeFinder(router, resolver, ctx, errorResponder) {
|
|
4200
4579
|
return function() {
|
|
4201
4580
|
const url = ctx.request.url();
|
|
4202
4581
|
const method = ctx.request.method();
|
|
4203
4582
|
const hostname = router.usingDomains ? ctx.request.hostname() : void 0;
|
|
4204
|
-
const route = router.match(url, method, hostname);
|
|
4583
|
+
const route = router.match(url, method, ctx.request.parsedUrl.shouldDecodeParam, hostname);
|
|
4205
4584
|
if (route) {
|
|
4206
4585
|
ctx.params = route.params;
|
|
4207
4586
|
ctx.subdomains = route.subdomains;
|
|
@@ -4230,7 +4609,14 @@ function writeResponse(ctx) {
|
|
|
4230
4609
|
function middlewareHandler(resolver, ctx) {
|
|
4231
4610
|
return function(fn, next) {
|
|
4232
4611
|
debug_default("executing middleware %s", fn.name);
|
|
4233
|
-
return
|
|
4612
|
+
return httpMiddleware.tracePromise(
|
|
4613
|
+
fn.handle,
|
|
4614
|
+
fn,
|
|
4615
|
+
void 0,
|
|
4616
|
+
resolver,
|
|
4617
|
+
ctx,
|
|
4618
|
+
next
|
|
4619
|
+
);
|
|
4234
4620
|
};
|
|
4235
4621
|
}
|
|
4236
4622
|
|
|
@@ -4308,7 +4694,13 @@ var Server = class {
|
|
|
4308
4694
|
*/
|
|
4309
4695
|
#requestErrorResponder = (error, ctx) => {
|
|
4310
4696
|
this.#resolvedErrorHandler.report(error, ctx);
|
|
4311
|
-
return
|
|
4697
|
+
return httpExceptionHandler.tracePromise(
|
|
4698
|
+
this.#resolvedErrorHandler.handle,
|
|
4699
|
+
void 0,
|
|
4700
|
+
void 0,
|
|
4701
|
+
error,
|
|
4702
|
+
ctx
|
|
4703
|
+
);
|
|
4312
4704
|
};
|
|
4313
4705
|
/**
|
|
4314
4706
|
* Check if the server has already been booted
|
|
@@ -4357,7 +4749,7 @@ var Server = class {
|
|
|
4357
4749
|
* Handles the HTTP request
|
|
4358
4750
|
*/
|
|
4359
4751
|
#handleRequest(ctx, resolver) {
|
|
4360
|
-
return this.#serverMiddlewareStack.runner().errorHandler((error) => this.#requestErrorResponder(error, ctx)).finalHandler(
|
|
4752
|
+
return this.#serverMiddlewareStack.runner().errorHandler((error) => this.#requestErrorResponder(error, ctx)).finalHandler(routeFinder(this.#router, resolver, ctx, this.#requestErrorResponder)).run(middlewareHandler(resolver, ctx)).catch((error) => {
|
|
4361
4753
|
ctx.logger.fatal({ err: error }, "Exception raised by error handler");
|
|
4362
4754
|
return this.#defaultErrorHandler.handle(error, ctx);
|
|
4363
4755
|
}).finally(writeResponse(ctx));
|
|
@@ -4368,7 +4760,10 @@ var Server = class {
|
|
|
4368
4760
|
pipeline(middleware) {
|
|
4369
4761
|
const middlewareStack = new Middleware2();
|
|
4370
4762
|
middleware.forEach((one) => {
|
|
4371
|
-
middlewareStack.add(
|
|
4763
|
+
middlewareStack.add({
|
|
4764
|
+
reference: one,
|
|
4765
|
+
...moduleCaller2(one, "handle").toHandleMethod()
|
|
4766
|
+
});
|
|
4372
4767
|
});
|
|
4373
4768
|
middlewareStack.freeze();
|
|
4374
4769
|
const stackRunner = middlewareStack.runner();
|
|
@@ -4395,7 +4790,10 @@ var Server = class {
|
|
|
4395
4790
|
*/
|
|
4396
4791
|
use(middleware) {
|
|
4397
4792
|
middleware.forEach(
|
|
4398
|
-
(one) => this.#middleware.push(
|
|
4793
|
+
(one) => this.#middleware.push({
|
|
4794
|
+
reference: one,
|
|
4795
|
+
...moduleImporter4(one, "handle").toHandleMethod()
|
|
4796
|
+
})
|
|
4399
4797
|
);
|
|
4400
4798
|
return this;
|
|
4401
4799
|
}
|
|
@@ -4476,6 +4874,12 @@ var Server = class {
|
|
|
4476
4874
|
resolver
|
|
4477
4875
|
);
|
|
4478
4876
|
}
|
|
4877
|
+
/**
|
|
4878
|
+
* Returns a list of server middleware stack
|
|
4879
|
+
*/
|
|
4880
|
+
getMiddlewareList() {
|
|
4881
|
+
return this.#serverMiddlewareStack ? Array.from(this.#serverMiddlewareStack.all()) : [...this.#middleware];
|
|
4882
|
+
}
|
|
4479
4883
|
/**
|
|
4480
4884
|
* Handle request
|
|
4481
4885
|
*/
|
|
@@ -4497,15 +4901,18 @@ var Server = class {
|
|
|
4497
4901
|
});
|
|
4498
4902
|
}
|
|
4499
4903
|
if (this.usingAsyncLocalStorage) {
|
|
4500
|
-
return asyncLocalStorage.storage.run(
|
|
4904
|
+
return asyncLocalStorage.storage.run(
|
|
4905
|
+
ctx,
|
|
4906
|
+
() => httpRequest.tracePromise(this.#handleRequest, ctx, this, ctx, resolver)
|
|
4907
|
+
);
|
|
4501
4908
|
}
|
|
4502
|
-
return this.#handleRequest
|
|
4909
|
+
return httpRequest.tracePromise(this.#handleRequest, ctx, this, ctx, resolver);
|
|
4503
4910
|
}
|
|
4504
4911
|
};
|
|
4505
4912
|
|
|
4506
4913
|
// src/define_config.ts
|
|
4507
4914
|
import proxyAddr from "proxy-addr";
|
|
4508
|
-
import
|
|
4915
|
+
import string2 from "@poppinss/utils/string";
|
|
4509
4916
|
import lodash3 from "@poppinss/utils/lodash";
|
|
4510
4917
|
function defineConfig(config) {
|
|
4511
4918
|
const { trustProxy: trustProxy2, ...rest } = config;
|
|
@@ -4513,7 +4920,10 @@ function defineConfig(config) {
|
|
|
4513
4920
|
allowMethodSpoofing: false,
|
|
4514
4921
|
trustProxy: proxyAddr.compile("loopback"),
|
|
4515
4922
|
subdomainOffset: 2,
|
|
4516
|
-
generateRequestId:
|
|
4923
|
+
generateRequestId: !!config.createRequestId,
|
|
4924
|
+
createRequestId() {
|
|
4925
|
+
return crypto.randomUUID();
|
|
4926
|
+
},
|
|
4517
4927
|
useAsyncLocalStorage: false,
|
|
4518
4928
|
etag: false,
|
|
4519
4929
|
jsonpCallbackName: "callback",
|
|
@@ -4542,7 +4952,7 @@ function defineConfig(config) {
|
|
|
4542
4952
|
};
|
|
4543
4953
|
const normalizedConfig = lodash3.merge({}, defaults, rest);
|
|
4544
4954
|
if (normalizedConfig.cookie.maxAge) {
|
|
4545
|
-
normalizedConfig.cookie.maxAge =
|
|
4955
|
+
normalizedConfig.cookie.maxAge = string2.seconds.parse(normalizedConfig.cookie.maxAge);
|
|
4546
4956
|
}
|
|
4547
4957
|
if (typeof trustProxy2 === "boolean") {
|
|
4548
4958
|
const tpValue = trustProxy2;
|
|
@@ -4557,19 +4967,21 @@ function defineConfig(config) {
|
|
|
4557
4967
|
}
|
|
4558
4968
|
|
|
4559
4969
|
export {
|
|
4970
|
+
E_ROUTE_NOT_FOUND,
|
|
4971
|
+
E_CANNOT_LOOKUP_ROUTE,
|
|
4972
|
+
E_HTTP_EXCEPTION,
|
|
4973
|
+
E_HTTP_REQUEST_ABORTED,
|
|
4974
|
+
errors_exports,
|
|
4975
|
+
CookieClient,
|
|
4976
|
+
canWriteResponseBody,
|
|
4977
|
+
tracing_channels_exports,
|
|
4560
4978
|
Route,
|
|
4561
4979
|
BriskRoute,
|
|
4562
4980
|
RouteResource,
|
|
4563
4981
|
RouteGroup,
|
|
4564
4982
|
parseRange,
|
|
4565
|
-
CookieClient,
|
|
4566
4983
|
Request,
|
|
4567
4984
|
Redirect,
|
|
4568
|
-
E_ROUTE_NOT_FOUND,
|
|
4569
|
-
E_CANNOT_LOOKUP_ROUTE,
|
|
4570
|
-
E_HTTP_EXCEPTION,
|
|
4571
|
-
E_HTTP_REQUEST_ABORTED,
|
|
4572
|
-
exceptions_exports,
|
|
4573
4985
|
ResponseStatus,
|
|
4574
4986
|
Response,
|
|
4575
4987
|
Qs,
|
|
@@ -4578,4 +4990,3 @@ export {
|
|
|
4578
4990
|
Server,
|
|
4579
4991
|
defineConfig
|
|
4580
4992
|
};
|
|
4581
|
-
//# sourceMappingURL=chunk-6FSCILWX.js.map
|