@adonisjs/http-server 8.0.0-next.1 → 8.0.0-next.10
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-2QM3D5BN.js +87 -0
- package/build/chunk-5PWHBE2E.js +128 -0
- package/build/chunk-QDK57QGB.js +1176 -0
- package/build/{chunk-HMYAZG76.js → chunk-YBLFT4O6.js} +1146 -1663
- package/build/factories/http_context.d.ts +2 -1
- package/build/factories/http_server.d.ts +7 -0
- package/build/factories/main.js +33 -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 +3 -2
- package/build/index.d.ts +4 -1
- package/build/index.js +97 -42
- package/build/src/client/helpers.d.ts +37 -0
- package/build/src/client/types.d.ts +203 -0
- package/build/src/client/url_builder.d.ts +15 -0
- package/build/src/client/url_builder.js +12 -0
- package/build/src/cookies/client.d.ts +61 -3
- 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 +21 -2
- package/build/src/debug.d.ts +13 -0
- package/build/src/define_config.d.ts +20 -4
- package/build/src/define_middleware.d.ts +20 -4
- package/build/src/errors.d.ts +60 -5
- package/build/src/exception_handler.d.ts +93 -39
- package/build/src/helpers.d.ts +57 -0
- package/build/src/helpers.js +9 -1
- package/build/src/http_context/local_storage.d.ts +17 -0
- package/build/src/http_context/main.d.ts +68 -10
- package/build/src/qs.d.ts +30 -2
- package/build/src/redirect.d.ts +84 -12
- package/build/src/request.d.ts +118 -12
- package/build/src/response.d.ts +416 -203
- package/build/src/response_status.d.ts +14 -0
- 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 +18 -1
- package/build/src/router/legacy/url_builder.d.ts +14 -14
- package/build/src/router/main.d.ts +79 -22
- package/build/src/router/matchers.d.ts +3 -0
- package/build/src/router/resource.d.ts +34 -1
- package/build/src/router/route.d.ts +28 -3
- package/build/src/router/signed_url_builder.d.ts +4 -8
- package/build/src/router/store.d.ts +9 -0
- 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 +34 -9
- 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 +42 -42
- 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 +10 -135
- package/build/src/utils.d.ts +71 -6
- package/package.json +26 -22
- package/build/chunk-ASX56VAK.js +0 -76
- package/build/src/router/url_builder.d.ts +0 -14
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/client/helpers.ts
|
|
8
|
+
function findRoute(domainsRoutes, routeIdentifier, domain, method, disableLegacyLookup) {
|
|
9
|
+
if (!domain) {
|
|
10
|
+
let route = null;
|
|
11
|
+
for (const routeDomain of Object.keys(domainsRoutes)) {
|
|
12
|
+
route = findRoute(domainsRoutes, routeIdentifier, routeDomain, method, disableLegacyLookup);
|
|
13
|
+
if (route) {
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return route;
|
|
18
|
+
}
|
|
19
|
+
const routes = domainsRoutes[domain];
|
|
20
|
+
if (!routes) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const lookupByName = true;
|
|
24
|
+
const lookupByPattern = !disableLegacyLookup;
|
|
25
|
+
const lookupByController = !disableLegacyLookup;
|
|
26
|
+
return routes.find((route) => {
|
|
27
|
+
if (method && !route.methods.includes(method)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (lookupByName && route.name === routeIdentifier || lookupByPattern && route.pattern === routeIdentifier) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (lookupByController && route.handler && typeof route.handler === "object") {
|
|
34
|
+
return "reference" in route.handler && route.handler.reference === routeIdentifier;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}) || null;
|
|
38
|
+
}
|
|
39
|
+
function createURL(pattern, tokens, searchParamsStringifier, params, options) {
|
|
40
|
+
const uriSegments = [];
|
|
41
|
+
const paramsArray = Array.isArray(params) ? params : null;
|
|
42
|
+
const paramsObject = !Array.isArray(params) ? params ?? {} : {};
|
|
43
|
+
let paramsIndex = 0;
|
|
44
|
+
for (const token of tokens) {
|
|
45
|
+
if (token.type === 0) {
|
|
46
|
+
uriSegments.push(token.val === "/" ? "" : `${token.val}${token.end}`);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (token.type === 2) {
|
|
50
|
+
const values = paramsArray ? paramsArray.slice(paramsIndex) : paramsObject["*"];
|
|
51
|
+
if (!Array.isArray(values) || !values.length) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`Cannot make URL for "${pattern}". Invalid value provided for the wildcard param`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
uriSegments.push(`${values.join("/")}${token.end}`);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
const paramName = token.val;
|
|
60
|
+
const value = paramsArray ? paramsArray[paramsIndex] : paramsObject[paramName];
|
|
61
|
+
const isDefined = value !== void 0 && value !== null;
|
|
62
|
+
if (token.type === 1 && !isDefined) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`Cannot make URL for "${pattern}". Missing value for the "${paramName}" param`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
if (isDefined) {
|
|
68
|
+
uriSegments.push(`${value}${token.end}`);
|
|
69
|
+
}
|
|
70
|
+
paramsIndex++;
|
|
71
|
+
}
|
|
72
|
+
let URI = `/${uriSegments.join("/")}`;
|
|
73
|
+
if (options?.prefixUrl) {
|
|
74
|
+
URI = `${options?.prefixUrl.replace(/\/$/, "")}${URI}`;
|
|
75
|
+
}
|
|
76
|
+
if (options?.qs) {
|
|
77
|
+
const queryString = searchParamsStringifier(options?.qs);
|
|
78
|
+
URI = queryString ? `${URI}?${queryString}` : URI;
|
|
79
|
+
}
|
|
80
|
+
return URI;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
__export,
|
|
85
|
+
findRoute,
|
|
86
|
+
createURL
|
|
87
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createURL,
|
|
3
|
+
findRoute
|
|
4
|
+
} from "./chunk-2QM3D5BN.js";
|
|
5
|
+
|
|
6
|
+
// src/client/url_builder.ts
|
|
7
|
+
function createUrlBuilder(routesLoader, searchParamsStringifier) {
|
|
8
|
+
let domainsList;
|
|
9
|
+
let domainsRoutes;
|
|
10
|
+
function createUrlForRoute(identifier, params, options, method) {
|
|
11
|
+
if (!domainsRoutes) {
|
|
12
|
+
domainsRoutes = typeof routesLoader === "function" ? routesLoader() : routesLoader;
|
|
13
|
+
}
|
|
14
|
+
if (!domainsList) {
|
|
15
|
+
domainsList = Object.keys(domainsRoutes).filter((domain2) => domain2 !== "root");
|
|
16
|
+
}
|
|
17
|
+
const domain = domainsList.find((name) => identifier.startsWith(`${name}@`));
|
|
18
|
+
const routeIdentifier = domain ? identifier.replace(new RegExp(`^${domain}@`), "") : identifier;
|
|
19
|
+
const route = findRoute(domainsRoutes, routeIdentifier, domain, method, true);
|
|
20
|
+
if (!route) {
|
|
21
|
+
throw new Error(`Cannot lookup route "${routeIdentifier}"`);
|
|
22
|
+
}
|
|
23
|
+
return createURL(
|
|
24
|
+
route.name ?? route.pattern,
|
|
25
|
+
route.tokens,
|
|
26
|
+
searchParamsStringifier,
|
|
27
|
+
params,
|
|
28
|
+
options
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
const urlFor = function route(...[identifier, params, options]) {
|
|
32
|
+
return createUrlForRoute(identifier, params, options);
|
|
33
|
+
};
|
|
34
|
+
urlFor.get = function urlForMethodGet(...[identifier, params, options]) {
|
|
35
|
+
const method = "GET";
|
|
36
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
37
|
+
return {
|
|
38
|
+
url,
|
|
39
|
+
method,
|
|
40
|
+
toString() {
|
|
41
|
+
return url;
|
|
42
|
+
},
|
|
43
|
+
form: {
|
|
44
|
+
action: url,
|
|
45
|
+
method
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
urlFor.post = function urlForMethodPost(...[identifier, params, options]) {
|
|
50
|
+
const method = "POST";
|
|
51
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
52
|
+
return {
|
|
53
|
+
url,
|
|
54
|
+
method,
|
|
55
|
+
toString() {
|
|
56
|
+
return url;
|
|
57
|
+
},
|
|
58
|
+
form: {
|
|
59
|
+
action: url,
|
|
60
|
+
method
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
urlFor.put = function urlForMethodPut(...[identifier, params, options]) {
|
|
65
|
+
const method = "PUT";
|
|
66
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
67
|
+
return {
|
|
68
|
+
url,
|
|
69
|
+
method,
|
|
70
|
+
toString() {
|
|
71
|
+
return url;
|
|
72
|
+
},
|
|
73
|
+
form: {
|
|
74
|
+
action: url,
|
|
75
|
+
method
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
urlFor.patch = function urlForMethodPatch(...[identifier, params, options]) {
|
|
80
|
+
const method = "PATCH";
|
|
81
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
82
|
+
return {
|
|
83
|
+
url,
|
|
84
|
+
method,
|
|
85
|
+
toString() {
|
|
86
|
+
return url;
|
|
87
|
+
},
|
|
88
|
+
form: {
|
|
89
|
+
action: url,
|
|
90
|
+
method
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
urlFor.delete = function urlForMethodDelete(...[identifier, params, options]) {
|
|
95
|
+
const method = "DELETE";
|
|
96
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
97
|
+
return {
|
|
98
|
+
url,
|
|
99
|
+
method,
|
|
100
|
+
toString() {
|
|
101
|
+
return url;
|
|
102
|
+
},
|
|
103
|
+
form: {
|
|
104
|
+
action: url,
|
|
105
|
+
method
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
urlFor.method = function urlForCustomMethod(method, ...[identifier, params, options]) {
|
|
110
|
+
const url = createUrlForRoute(identifier, params, options, method);
|
|
111
|
+
return {
|
|
112
|
+
url,
|
|
113
|
+
method,
|
|
114
|
+
toString() {
|
|
115
|
+
return url;
|
|
116
|
+
},
|
|
117
|
+
form: {
|
|
118
|
+
action: url,
|
|
119
|
+
method
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
return urlFor;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
createUrlBuilder
|
|
128
|
+
};
|