acrylblends 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/docs/framework/UPSTREAM.md +1 -1
- package/docs/framework/api/presets.md +0 -3
- package/docs/framework/cordis/acryl-in-a-cordis-app.md +3 -0
- package/docs/framework/getting-started/basic.md +4 -4
- package/docs/framework/guides/jsx.md +1 -1
- package/docs/framework/guides/middleware.md +1 -1
- package/docs/framework/helpers/cookie.md +1 -1
- package/docs/framework/helpers/dev.md +0 -3
- package/docs/framework/helpers/jwt.md +1 -1
- package/docs/framework/helpers/proxy.md +0 -3
- package/docs/framework/middleware/builtin/basic-auth.md +6 -6
- package/docs/framework/middleware/builtin/cache.md +0 -3
- package/docs/framework/middleware/builtin/combine.md +1 -1
- package/docs/framework/middleware/builtin/ip-restriction.md +1 -1
- package/docs/framework/middleware/builtin/logger.md +1 -1
- package/docs/framework/middleware/builtin/mount.md +0 -3
- package/docs/framework/upstream.json +2 -2
- package/lib/accepts.d.ts +1 -1
- package/lib/acryl-base.d.ts +1 -1
- package/lib/adapter.d.ts +1 -1
- package/lib/{app-CmAYW1Al.d.ts → app-BdrVHBlJ.d.ts} +1 -1
- package/lib/basic-auth.d.ts +1 -1
- package/lib/bearer-auth.d.ts +1 -1
- package/lib/body-limit.d.ts +1 -1
- package/lib/cache.d.ts +43 -0
- package/lib/cache.js +169 -0
- package/lib/client.d.ts +2 -2
- package/lib/combine.d.ts +1 -1
- package/lib/compress.d.ts +1 -1
- package/lib/conninfo.d.ts +2 -2
- package/lib/{context-Bm7rI-oK.d.ts → context-B5Y1lLha.d.ts} +1 -1
- package/lib/context-storage.d.ts +1 -1
- package/lib/{cookie-ClMaKDQf.d.ts → cookie-D9_nQbsM.d.ts} +1 -1
- package/lib/cookie.d.ts +3 -3
- package/lib/cors.d.ts +1 -1
- package/lib/csrf.d.ts +1 -1
- package/lib/dev.d.ts +19 -0
- package/lib/dev.js +50 -0
- package/lib/etag.d.ts +1 -1
- package/lib/factory.d.ts +2 -2
- package/lib/{index-B-3F4wt2.d.ts → index-DtEoak1i.d.ts} +2 -2
- package/lib/{index-UTBmM3GX.d.ts → index-Kqou8Fjh.d.ts} +2 -2
- package/lib/{index-oOClm_Xk.d.ts → index-m12zcmph.d.ts} +3 -3
- package/lib/index.d.ts +4 -4
- package/lib/ip-restriction.d.ts +2 -2
- package/lib/jwk.d.ts +4 -4
- package/lib/{jwt-Dg493Tai.d.ts → jwt-BA65QhnJ.d.ts} +1 -1
- package/lib/jwt.d.ts +4 -4
- package/lib/language.d.ts +1 -1
- package/lib/linear-router-C3FPib6h.js +96 -0
- package/lib/logger.d.ts +1 -1
- package/lib/loopback-only.d.ts +1 -1
- package/lib/method-not-allowed.d.ts +2 -2
- package/lib/method-override.d.ts +2 -2
- package/lib/mount.d.ts +44 -0
- package/lib/mount.js +67 -0
- package/lib/node-server/conninfo.d.ts +1 -1
- package/lib/node-server/serve-static.d.ts +1 -1
- package/lib/node-server.d.ts +1 -1
- package/lib/pattern-router-HZxjDGEQ.js +41 -0
- package/lib/powered-by.d.ts +1 -1
- package/lib/pretty-json.d.ts +1 -1
- package/lib/proxy.d.ts +72 -0
- package/lib/proxy.js +121 -0
- package/lib/quick.d.ts +8 -0
- package/lib/quick.js +17 -0
- package/lib/request-id.d.ts +1 -1
- package/lib/request.d.ts +1 -1
- package/lib/route.d.ts +1 -1
- package/lib/router/linear-router.js +1 -95
- package/lib/router/pattern-router.js +1 -40
- package/lib/schema-validator.d.ts +1 -1
- package/lib/secure-headers.d.ts +1 -1
- package/lib/serve-static.d.ts +1 -1
- package/lib/streaming.d.ts +1 -1
- package/lib/testing.d.ts +4 -4
- package/lib/timeout.d.ts +1 -1
- package/lib/timing.d.ts +1 -1
- package/lib/tiny.d.ts +8 -0
- package/lib/tiny.js +15 -0
- package/lib/trailing-slash.d.ts +1 -1
- package/lib/{types-CHesD1KG.d.ts → types-Bd29gh2o.d.ts} +3 -3
- package/lib/{types-CwrQjlaM.d.ts → types-D9DEXMjE.d.ts} +3 -1
- package/lib/{types-CDO6I3B0.d.ts → types-ZM9gIiKh.d.ts} +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/utils/body.d.ts +1 -1
- package/lib/utils/cookie.d.ts +1 -1
- package/lib/utils/crypto.d.ts +1 -1
- package/lib/utils/ipaddr.d.ts +1 -1
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/types.d.ts +2 -2
- package/lib/validator.d.ts +2 -2
- package/lib/ws.d.ts +1 -1
- package/package.json +25 -1
- package/plugins/acryl-inspect/upstream.json +1 -1
- package/plugins/acryl-node-server/upstream.json +1 -1
- package/plugins/acryl-router/src/core/helper/dev/index.test.ts +181 -0
- package/plugins/acryl-router/src/core/helper/dev/index.ts +79 -0
- package/plugins/acryl-router/src/core/helper/proxy/index.test.ts +356 -0
- package/plugins/acryl-router/src/core/helper/proxy/index.ts +203 -0
- package/plugins/acryl-router/src/core/middleware/cache/index.test.ts +1211 -0
- package/plugins/acryl-router/src/core/middleware/cache/index.ts +323 -0
- package/plugins/acryl-router/src/core/middleware/mount/index.test.ts +334 -0
- package/plugins/acryl-router/src/core/middleware/mount/index.ts +108 -0
- package/plugins/acryl-router/src/core/preset/quick.test.ts +42 -0
- package/plugins/acryl-router/src/core/preset/quick.ts +24 -0
- package/plugins/acryl-router/src/core/preset/tiny.test.ts +42 -0
- package/plugins/acryl-router/src/core/preset/tiny.ts +20 -0
- package/plugins/acryl-router/src/core/utils/types.ts +3 -0
- package/plugins/acryl-router/src/helpers/index.ts +2 -0
- package/plugins/acryl-router/src/middleware/index.ts +2 -0
- package/plugins/acryl-router/src/service.ts +22 -5
- package/plugins/acryl-router/upstream.json +2 -2
- package/plugins/acryl-router-http/upstream.json +1 -1
- package/plugins/acryl-state/upstream.json +1 -1
- package/plugins/desktop/upstream.json +1 -1
- package/plugins/desktop-web/upstream.json +1 -1
- package/templates/todo/upstream.json +1 -1
package/lib/proxy.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { HTTPException } from "./http-exception.js";
|
|
2
|
+
//#region ../../plugins/acryl-router/src/core/helper/proxy/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* @module
|
|
5
|
+
* Proxy Helper for Acryl.
|
|
6
|
+
*/
|
|
7
|
+
const hopByHopHeaders = [
|
|
8
|
+
"connection",
|
|
9
|
+
"keep-alive",
|
|
10
|
+
"proxy-authenticate",
|
|
11
|
+
"proxy-authorization",
|
|
12
|
+
"te",
|
|
13
|
+
"trailer",
|
|
14
|
+
"transfer-encoding",
|
|
15
|
+
"upgrade"
|
|
16
|
+
];
|
|
17
|
+
const ALLOWED_TOKEN_PATTERN = /^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/;
|
|
18
|
+
const buildRequestInitFromRequest = (request, strictConnectionProcessing) => {
|
|
19
|
+
if (!request) return {};
|
|
20
|
+
const headers = new Headers(request.headers);
|
|
21
|
+
if (strictConnectionProcessing) {
|
|
22
|
+
const connectionValue = headers.get("connection");
|
|
23
|
+
if (connectionValue) {
|
|
24
|
+
const headerNames = connectionValue.split(",").map((h) => h.trim());
|
|
25
|
+
const invalidHeaders = headerNames.filter((h) => !ALLOWED_TOKEN_PATTERN.test(h));
|
|
26
|
+
if (invalidHeaders.length > 0) throw new HTTPException(400, { message: `Invalid Connection header value: ${invalidHeaders.join(", ")}` });
|
|
27
|
+
headerNames.forEach((headerName) => {
|
|
28
|
+
headers.delete(headerName);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
hopByHopHeaders.forEach((header) => {
|
|
33
|
+
headers.delete(header);
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
method: request.method,
|
|
37
|
+
body: request.body,
|
|
38
|
+
duplex: request.body ? "half" : void 0,
|
|
39
|
+
headers,
|
|
40
|
+
signal: request.signal
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const preprocessRequestInit = (requestInit) => {
|
|
44
|
+
if (!requestInit.headers || Array.isArray(requestInit.headers) || requestInit.headers instanceof Headers) return requestInit;
|
|
45
|
+
const headers = new Headers();
|
|
46
|
+
for (const [key, value] of Object.entries(requestInit.headers)) if (value == null) headers.delete(key);
|
|
47
|
+
else headers.set(key, value);
|
|
48
|
+
requestInit.headers = headers;
|
|
49
|
+
return requestInit;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Fetch API wrapper for proxy.
|
|
53
|
+
* The parameters and return value are the same as for `fetch` (except for the proxy-specific options).
|
|
54
|
+
*
|
|
55
|
+
* The "Accept-Encoding" header is replaced with an encoding that the current runtime can handle.
|
|
56
|
+
* Unnecessary response headers are deleted and a Response object is returned that can be returned
|
|
57
|
+
* as is as a response from the handler.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* app.get('/proxy/:path', (c) => {
|
|
62
|
+
* return proxy(`http://${originServer}/${c.req.param('path')}`, {
|
|
63
|
+
* headers: {
|
|
64
|
+
* ...c.req.header(), // optional, specify only when forwarding all the request data (including credentials) is necessary.
|
|
65
|
+
* 'X-Forwarded-For': '127.0.0.1',
|
|
66
|
+
* 'X-Forwarded-Host': c.req.header('host'),
|
|
67
|
+
* Authorization: undefined, // do not propagate request headers contained in c.req.header('Authorization')
|
|
68
|
+
* },
|
|
69
|
+
* }).then((res) => {
|
|
70
|
+
* res.headers.delete('Set-Cookie')
|
|
71
|
+
* return res
|
|
72
|
+
* })
|
|
73
|
+
* })
|
|
74
|
+
*
|
|
75
|
+
* app.all('/proxy/:path', (c) => {
|
|
76
|
+
* return proxy(`http://${originServer}/${c.req.param('path')}`, {
|
|
77
|
+
* ...c.req, // optional, specify only when forwarding all the request data (including credentials) is necessary.
|
|
78
|
+
* headers: {
|
|
79
|
+
* ...c.req.header(),
|
|
80
|
+
* 'X-Forwarded-For': '127.0.0.1',
|
|
81
|
+
* 'X-Forwarded-Host': c.req.header('host'),
|
|
82
|
+
* Authorization: undefined, // do not propagate request headers contained in c.req.header('Authorization')
|
|
83
|
+
* },
|
|
84
|
+
* })
|
|
85
|
+
* })
|
|
86
|
+
*
|
|
87
|
+
* // Strict RFC compliance mode (use only in trusted environments)
|
|
88
|
+
* app.get('/internal-proxy/:path', (c) => {
|
|
89
|
+
* return proxy(`http://${internalServer}/${c.req.param('path')}`, {
|
|
90
|
+
* ...c.req,
|
|
91
|
+
* strictConnectionProcessing: true,
|
|
92
|
+
* })
|
|
93
|
+
* })
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
const proxy = async (input, proxyInit) => {
|
|
97
|
+
const { raw, customFetch, strictConnectionProcessing = false, ...requestInit } = proxyInit instanceof Request ? { raw: proxyInit } : proxyInit ?? {};
|
|
98
|
+
const req = new Request(input, {
|
|
99
|
+
...buildRequestInitFromRequest(raw, strictConnectionProcessing),
|
|
100
|
+
...preprocessRequestInit(requestInit)
|
|
101
|
+
});
|
|
102
|
+
req.headers.delete("accept-encoding");
|
|
103
|
+
const res = await (customFetch || fetch)(req);
|
|
104
|
+
const resHeaders = new Headers(res.headers);
|
|
105
|
+
const connectionValue = resHeaders.get("connection");
|
|
106
|
+
if (connectionValue) connectionValue.split(",").map((h) => h.trim()).filter((h) => ALLOWED_TOKEN_PATTERN.test(h)).forEach((h) => resHeaders.delete(h));
|
|
107
|
+
hopByHopHeaders.forEach((header) => {
|
|
108
|
+
resHeaders.delete(header);
|
|
109
|
+
});
|
|
110
|
+
if (resHeaders.has("content-encoding")) {
|
|
111
|
+
resHeaders.delete("content-encoding");
|
|
112
|
+
resHeaders.delete("content-length");
|
|
113
|
+
}
|
|
114
|
+
return new Response(res.body, {
|
|
115
|
+
status: res.status,
|
|
116
|
+
statusText: res.statusText,
|
|
117
|
+
headers: resHeaders
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
//#endregion
|
|
121
|
+
export { proxy };
|
package/lib/quick.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { $ as Acryl$1, J as Schema, _ as Env, et as AcrylOptions, h as BlankSchema, p as BlankEnv } from "./context-B5Y1lLha.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../plugins/acryl-router/src/core/preset/quick.d.ts
|
|
4
|
+
declare class Acryl<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = '/'> extends Acryl$1<E, S, BasePath> {
|
|
5
|
+
constructor(options?: AcrylOptions<E>);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { Acryl };
|
package/lib/quick.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AcrylBase as Acryl$1 } from "./acryl-base.js";
|
|
2
|
+
import { t as SmartRouter } from "./smart-router-C5CZ5XSM.js";
|
|
3
|
+
import { t as TrieRouter } from "./trie-router-CfFbapzL.js";
|
|
4
|
+
import { t as LinearRouter } from "./linear-router-C3FPib6h.js";
|
|
5
|
+
//#region ../../plugins/acryl-router/src/core/preset/quick.ts
|
|
6
|
+
/**
|
|
7
|
+
* @module
|
|
8
|
+
* The preset that uses `LinearRouter`.
|
|
9
|
+
*/
|
|
10
|
+
var Acryl = class extends Acryl$1 {
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
super(options);
|
|
13
|
+
this.router = new SmartRouter({ routers: [new LinearRouter(), new TrieRouter()] });
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Acryl };
|
package/lib/request-id.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as MiddlewareHandler, t as Context } from "./context-
|
|
1
|
+
import { I as MiddlewareHandler, t as Context } from "./context-B5Y1lLha.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../plugins/acryl-router/src/core/middleware/request-id/request-id.d.ts
|
|
4
4
|
type RequestIdVariables = {
|
package/lib/request.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { o as AcrylRequest, s as cloneRawRequest } from "./context-
|
|
1
|
+
import { o as AcrylRequest, s as cloneRawRequest } from "./context-B5Y1lLha.js";
|
|
2
2
|
export { AcrylRequest, cloneRawRequest };
|
package/lib/route.d.ts
CHANGED
|
@@ -1,96 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UnsupportedPathError } from "../router.js";
|
|
3
|
-
//#region ../../plugins/acryl-router/src/core/router/linear-router/router.ts
|
|
4
|
-
const emptyParams = Object.create(null);
|
|
5
|
-
const splitPathRe = /\/(:\w+(?:{(?:(?:{[\d,]+})|[^}])+})?)|\/[^\/\?]+|(\?)/g;
|
|
6
|
-
const splitByStarRe = /\*/;
|
|
7
|
-
var LinearRouter = class {
|
|
8
|
-
name = "LinearRouter";
|
|
9
|
-
#routes = [];
|
|
10
|
-
add(method, path, handler) {
|
|
11
|
-
for (let i = 0, paths = checkOptionalParameter(path) || [path], len = paths.length; i < len; i++) this.#routes.push([
|
|
12
|
-
method,
|
|
13
|
-
paths[i],
|
|
14
|
-
handler
|
|
15
|
-
]);
|
|
16
|
-
}
|
|
17
|
-
match(method, path) {
|
|
18
|
-
const handlers = [];
|
|
19
|
-
ROUTES_LOOP: for (let i = 0, len = this.#routes.length; i < len; i++) {
|
|
20
|
-
const [routeMethod, routePath, handler] = this.#routes[i];
|
|
21
|
-
if (routeMethod === method || routeMethod === "ALL") {
|
|
22
|
-
if (routePath === "*" || routePath === "/*") {
|
|
23
|
-
handlers.push([handler, emptyParams]);
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
const hasStar = routePath.indexOf("*") !== -1;
|
|
27
|
-
const hasLabel = routePath.indexOf(":") !== -1;
|
|
28
|
-
if (!hasStar && !hasLabel) {
|
|
29
|
-
if (routePath === path || routePath + "/" === path) handlers.push([handler, emptyParams]);
|
|
30
|
-
} else if (hasStar && !hasLabel) {
|
|
31
|
-
const endsWithStar = routePath.charCodeAt(routePath.length - 1) === 42;
|
|
32
|
-
const endsWithSlashStar = routePath.endsWith("/*");
|
|
33
|
-
const parts = (endsWithStar ? routePath.slice(0, endsWithSlashStar ? -2 : -1) : routePath).split(splitByStarRe);
|
|
34
|
-
const lastIndex = parts.length - 1;
|
|
35
|
-
for (let j = 0, pos = 0, len = parts.length; j < len; j++) {
|
|
36
|
-
const part = parts[j];
|
|
37
|
-
if (path.indexOf(part, pos) !== pos) continue ROUTES_LOOP;
|
|
38
|
-
pos += part.length;
|
|
39
|
-
if (j === lastIndex) {
|
|
40
|
-
if (endsWithSlashStar) {
|
|
41
|
-
if (pos !== path.length && path.charCodeAt(pos) !== 47) continue ROUTES_LOOP;
|
|
42
|
-
} else if (!endsWithStar && pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) continue ROUTES_LOOP;
|
|
43
|
-
} else {
|
|
44
|
-
const index = path.indexOf("/", pos);
|
|
45
|
-
if (index === -1) continue ROUTES_LOOP;
|
|
46
|
-
pos = index;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
handlers.push([handler, emptyParams]);
|
|
50
|
-
} else if (hasLabel && !hasStar) {
|
|
51
|
-
const params = Object.create(null);
|
|
52
|
-
const parts = routePath.match(splitPathRe);
|
|
53
|
-
const lastIndex = parts.length - 1;
|
|
54
|
-
for (let j = 0, pos = 0, len = parts.length; j < len; j++) {
|
|
55
|
-
if (pos === -1 || pos >= path.length) continue ROUTES_LOOP;
|
|
56
|
-
const part = parts[j];
|
|
57
|
-
if (part.charCodeAt(1) === 58) {
|
|
58
|
-
if (path.charCodeAt(pos) !== 47) continue ROUTES_LOOP;
|
|
59
|
-
let name = part.slice(2);
|
|
60
|
-
let value;
|
|
61
|
-
if (name.charCodeAt(name.length - 1) === 125) {
|
|
62
|
-
const openBracePos = name.indexOf("{");
|
|
63
|
-
const next = parts[j + 1];
|
|
64
|
-
const lookahead = next && next[1] !== ":" && next[1] !== "*" ? `(?=${next})` : "";
|
|
65
|
-
const pattern = name.slice(openBracePos + 1, -1) + lookahead;
|
|
66
|
-
const restPath = path.slice(pos + 1);
|
|
67
|
-
const match = new RegExp(pattern, "d").exec(restPath);
|
|
68
|
-
if (!match || match.indices[0][0] !== 0 || match.indices[0][1] === 0) continue ROUTES_LOOP;
|
|
69
|
-
name = name.slice(0, openBracePos);
|
|
70
|
-
value = restPath.slice(...match.indices[0]);
|
|
71
|
-
pos += match.indices[0][1] + 1;
|
|
72
|
-
} else {
|
|
73
|
-
let endValuePos = path.indexOf("/", pos + 1);
|
|
74
|
-
if (endValuePos === -1) endValuePos = path.length;
|
|
75
|
-
if (endValuePos === pos + 1) continue ROUTES_LOOP;
|
|
76
|
-
value = path.slice(pos + 1, endValuePos);
|
|
77
|
-
pos = endValuePos;
|
|
78
|
-
}
|
|
79
|
-
params[name] ||= value;
|
|
80
|
-
} else {
|
|
81
|
-
if (path.indexOf(part, pos) !== pos) continue ROUTES_LOOP;
|
|
82
|
-
pos += part.length;
|
|
83
|
-
}
|
|
84
|
-
if (j === lastIndex) {
|
|
85
|
-
if (pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) continue ROUTES_LOOP;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
handlers.push([handler, params]);
|
|
89
|
-
} else if (hasLabel && hasStar) throw new UnsupportedPathError();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return [handlers];
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
//#endregion
|
|
1
|
+
import { t as LinearRouter } from "../linear-router-C3FPib6h.js";
|
|
96
2
|
export { LinearRouter };
|
|
@@ -1,41 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ../../plugins/acryl-router/src/core/router/pattern-router/router.ts
|
|
3
|
-
const emptyParams = Object.create(null);
|
|
4
|
-
var PatternRouter = class {
|
|
5
|
-
name = "PatternRouter";
|
|
6
|
-
#routes = [];
|
|
7
|
-
add(method, path, handler) {
|
|
8
|
-
const suffix = path.endsWith("/*") ? "(?:$|/)" : path.endsWith("*") ? "" : "/?$";
|
|
9
|
-
path = path.replace(/\*$/, "");
|
|
10
|
-
if (path.at(-1) === "?") {
|
|
11
|
-
path = path.slice(0, -1);
|
|
12
|
-
this.add(method, path.replace(/\/[^/]+$/, ""), handler);
|
|
13
|
-
}
|
|
14
|
-
const parts = (path.match(/\/?(:\w+(?:{(?:(?:{[\d,]+})|[^}])+})?)|\/?[^\/\?]+/g) || []).map((part) => {
|
|
15
|
-
const match = part.match(/^\/:([^{]+)(?:{(.*)})?/);
|
|
16
|
-
return match ? `/(?<${match[1]}>${match[2] || "[^/]+"})` : part === "/*" ? "/[^/]+" : part.replace(/[.\\+*[^\]$()]/g, "\\$&");
|
|
17
|
-
});
|
|
18
|
-
try {
|
|
19
|
-
this.#routes.push([
|
|
20
|
-
new RegExp(`^${parts.join("")}${suffix}`),
|
|
21
|
-
method,
|
|
22
|
-
handler
|
|
23
|
-
]);
|
|
24
|
-
} catch {
|
|
25
|
-
throw new UnsupportedPathError();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
match(method, path) {
|
|
29
|
-
const handlers = [];
|
|
30
|
-
for (let i = 0, len = this.#routes.length; i < len; i++) {
|
|
31
|
-
const [pattern, routeMethod, handler] = this.#routes[i];
|
|
32
|
-
if (routeMethod === method || routeMethod === "ALL") {
|
|
33
|
-
const match = pattern.exec(path);
|
|
34
|
-
if (match) handlers.push([handler, match.groups || emptyParams]);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return [handlers];
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
//#endregion
|
|
1
|
+
import { t as PatternRouter } from "../pattern-router-HZxjDGEQ.js";
|
|
41
2
|
export { PatternRouter };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as MiddlewareHandler, Z as ValidationTargets, _ as Env } from "./context-
|
|
1
|
+
import { I as MiddlewareHandler, Z as ValidationTargets, _ as Env } from "./context-B5Y1lLha.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../plugins/acryl-router/src/helpers/schema-validator.d.ts
|
|
4
4
|
/** The slice of the Standard Schema interface this needs; Schemastery (what Cordis uses), Zod and Valibot all implement it. */
|
package/lib/secure-headers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as MiddlewareHandler, t as Context } from "./context-
|
|
1
|
+
import { I as MiddlewareHandler, t as Context } from "./context-B5Y1lLha.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../plugins/acryl-router/src/core/middleware/secure-headers/permissions-policy.d.ts
|
|
4
4
|
type PermissionsPolicyDirective = StandardizedFeatures | ProposedFeatures | ExperimentalFeatures;
|
package/lib/serve-static.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as MiddlewareHandler, _ as Env, i as Data, t as Context } from "./context-
|
|
1
|
+
import { I as MiddlewareHandler, _ as Env, i as Data, t as Context } from "./context-B5Y1lLha.js";
|
|
2
2
|
|
|
3
3
|
//#region ../../plugins/acryl-router/src/core/middleware/serve-static/index.d.ts
|
|
4
4
|
type ServeStaticOptions<E extends Env = Env> = {
|
package/lib/streaming.d.ts
CHANGED
package/lib/testing.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { J as Schema, a as ExecutionContext } from "./context-
|
|
2
|
-
import {
|
|
3
|
-
import { t as Acryl } from "./app-
|
|
4
|
-
import { i as ClientRequestOptions, n as Client } from "./types-
|
|
1
|
+
import { J as Schema, a as ExecutionContext } from "./context-B5Y1lLha.js";
|
|
2
|
+
import { E as UnionToIntersection } from "./types-D9DEXMjE.js";
|
|
3
|
+
import { t as Acryl } from "./app-BdrVHBlJ.js";
|
|
4
|
+
import { i as ClientRequestOptions, n as Client } from "./types-Bd29gh2o.js";
|
|
5
5
|
|
|
6
6
|
//#region ../../plugins/acryl-router/src/core/helper/testing/index.d.ts
|
|
7
7
|
type ExtractEnv<T> = T extends Acryl<infer E, Schema, string> ? E : never;
|
package/lib/timeout.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as MiddlewareHandler, t as Context } from "./context-
|
|
1
|
+
import { I as MiddlewareHandler, t as Context } from "./context-B5Y1lLha.js";
|
|
2
2
|
import { HTTPException } from "./http-exception.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../plugins/acryl-router/src/core/middleware/timeout/index.d.ts
|
package/lib/timing.d.ts
CHANGED
package/lib/tiny.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { $ as Acryl$1, J as Schema, _ as Env, et as AcrylOptions, h as BlankSchema, p as BlankEnv } from "./context-B5Y1lLha.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../plugins/acryl-router/src/core/preset/tiny.d.ts
|
|
4
|
+
declare class Acryl<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = '/'> extends Acryl$1<E, S, BasePath> {
|
|
5
|
+
constructor(options?: AcrylOptions<E>);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { Acryl };
|
package/lib/tiny.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AcrylBase as Acryl$1 } from "./acryl-base.js";
|
|
2
|
+
import { t as PatternRouter } from "./pattern-router-HZxjDGEQ.js";
|
|
3
|
+
//#region ../../plugins/acryl-router/src/core/preset/tiny.ts
|
|
4
|
+
/**
|
|
5
|
+
* @module
|
|
6
|
+
* The preset that uses `PatternRouter`.
|
|
7
|
+
*/
|
|
8
|
+
var Acryl = class extends Acryl$1 {
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
super(options);
|
|
11
|
+
this.router = new PatternRouter();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { Acryl };
|
package/lib/trailing-slash.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as Acryl, J as Schema, K as ResponseFormat, N as KnownResponseFormat, g as Endpoint, x as ExtractSchema } from "./context-
|
|
1
|
+
import { $ as Acryl, J as Schema, K as ResponseFormat, N as KnownResponseFormat, g as Endpoint, x as ExtractSchema } from "./context-B5Y1lLha.js";
|
|
2
2
|
import { i as METHOD_NAME_ALL_LOWERCASE, n as METHODS } from "./router-CvUxUTOq.js";
|
|
3
3
|
import { c as StatusCode, l as SuccessStatusCode } from "./http-status-DaAwGAFL.js";
|
|
4
|
-
import { s as HasRequiredKeys } from "./types-
|
|
5
|
-
import { t as Acryl$1 } from "./app-
|
|
4
|
+
import { s as HasRequiredKeys } from "./types-D9DEXMjE.js";
|
|
5
|
+
import { t as Acryl$1 } from "./app-BdrVHBlJ.js";
|
|
6
6
|
|
|
7
7
|
//#region ../../plugins/acryl-router/src/core/client/types.d.ts
|
|
8
8
|
/**
|
|
@@ -62,6 +62,8 @@ type StringLiteralUnion<T> = T | (string & Record<never, never>);
|
|
|
62
62
|
type BufferSource = ArrayBufferView<ArrayBuffer> | ArrayBuffer;
|
|
63
63
|
/** A Web Crypto key, named from the runtime's own `crypto` so the public types do not need the DOM library. */
|
|
64
64
|
type CryptoKey = Awaited<ReturnType<typeof crypto.subtle.importKey>>;
|
|
65
|
+
/** What the Web `Headers` constructor accepts, named from the runtime's own `Headers` so the public types do not need the DOM library. */
|
|
66
|
+
type HeadersInit = NonNullable<ConstructorParameters<typeof Headers>[0]>;
|
|
65
67
|
/** How a WebSocket hands binary data to `onmessage`; declared here so the public types do not need the DOM library. */
|
|
66
68
|
type BinaryType = 'arraybuffer' | 'blob';
|
|
67
69
|
/** The members of a WebSocket `message` event the helpers hand out (the Web `MessageEvent`, whose Node global is not generic); declared here so the public types do not need the DOM library. */
|
|
@@ -102,4 +104,4 @@ interface JsonWebKey {
|
|
|
102
104
|
y?: string;
|
|
103
105
|
}
|
|
104
106
|
//#endregion
|
|
105
|
-
export {
|
|
107
|
+
export { Simplify as C, UnionToIntersection as E, RequiredKeysOf as S, StringLiteralUnion as T, JSONValue as _, Equal as a, NotEqual as b, HeadersInit as c, InvalidJSONValue as d, IsAny as f, JSONPrimitive as g, JSONParsed as h, CryptoKey as i, IfAnyThenEmptyObject as l, JSONObject as m, BufferSource as n, Expect as o, JSONArray as p, CloseEvent as r, HasRequiredKeys as s, BinaryType as t, InterfaceToType as u, JsonWebKey as v, SimplifyDeepArray as w, RemoveBlankRecord as x, MessageEvent as y };
|
package/lib/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as Input, B as NotFoundResponse, C as FetchEventLike, D as Handler, E as HTTPResponseError, F as MergeSchemaPath, G as RemoveQuestion, H as ParamKeyToRecord, I as MiddlewareHandler, J as Schema, K as ResponseFormat, L as MiddlewareHandlerInterface, M as IntersectNonAnyTypes, N as KnownResponseFormat, O as HandlerInterface, P as MergePath, Q as Variables, R as Next, S as ExtractSchemaForStatusCode, T as H, U as ParamKeys, V as OnHandlerInterface, W as ParsedFormValue, X as TypedResponse, Y as ToSchema, Z as ValidationTargets, _ as Env, b as ExtractInput, d as AddParam, f as Bindings, g as Endpoint, h as BlankSchema, j as InputToDataByTarget, k as HandlerResponse, m as BlankInput, p as BlankEnv, q as RouterRoute, v as ErrorHandler, w as FormValue, x as ExtractSchema, y as ExtractHandlerResponse, z as NotFoundHandler } from "./context-
|
|
1
|
+
import { A as Input, B as NotFoundResponse, C as FetchEventLike, D as Handler, E as HTTPResponseError, F as MergeSchemaPath, G as RemoveQuestion, H as ParamKeyToRecord, I as MiddlewareHandler, J as Schema, K as ResponseFormat, L as MiddlewareHandlerInterface, M as IntersectNonAnyTypes, N as KnownResponseFormat, O as HandlerInterface, P as MergePath, Q as Variables, R as Next, S as ExtractSchemaForStatusCode, T as H, U as ParamKeys, V as OnHandlerInterface, W as ParsedFormValue, X as TypedResponse, Y as ToSchema, Z as ValidationTargets, _ as Env, b as ExtractInput, d as AddParam, f as Bindings, g as Endpoint, h as BlankSchema, j as InputToDataByTarget, k as HandlerResponse, m as BlankInput, p as BlankEnv, q as RouterRoute, v as ErrorHandler, w as FormValue, x as ExtractSchema, y as ExtractHandlerResponse, z as NotFoundHandler } from "./context-B5Y1lLha.js";
|
|
2
2
|
export { AddParam, Bindings, BlankEnv, BlankInput, BlankSchema, Endpoint, Env, ErrorHandler, ExtractHandlerResponse, ExtractInput, ExtractSchema, ExtractSchemaForStatusCode, FetchEventLike, FormValue, H, HTTPResponseError, Handler, HandlerInterface, HandlerResponse, Input, InputToDataByTarget, IntersectNonAnyTypes, KnownResponseFormat, MergePath, MergeSchemaPath, MiddlewareHandler, MiddlewareHandlerInterface, Next, NotFoundHandler, NotFoundResponse, OnHandlerInterface, ParamKeyToRecord, ParamKeys, ParsedFormValue, RemoveQuestion, ResponseFormat, RouterRoute, Schema, ToSchema, TypedResponse, ValidationTargets, Variables };
|
package/lib/utils/body.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as BodyData, l as ParseBodyOptions, u as parseBody } from "../context-
|
|
1
|
+
import { c as BodyData, l as ParseBodyOptions, u as parseBody } from "../context-B5Y1lLha.js";
|
|
2
2
|
export { BodyData, ParseBodyOptions, parseBody };
|
package/lib/utils/cookie.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SignedCookie, c as serialize, i as CookiePrefixOptions, l as serializeSigned, n as CookieConstraint, o as parse, r as CookieOptions, s as parseSigned, t as Cookie } from "../cookie-
|
|
1
|
+
import { a as SignedCookie, c as serialize, i as CookiePrefixOptions, l as serializeSigned, n as CookieConstraint, o as parse, r as CookieOptions, s as parseSigned, t as Cookie } from "../cookie-D9_nQbsM.js";
|
|
2
2
|
export { Cookie, CookieConstraint, CookieOptions, CookiePrefixOptions, SignedCookie, parse, parseSigned, serialize, serializeSigned };
|
package/lib/utils/crypto.d.ts
CHANGED
package/lib/utils/ipaddr.d.ts
CHANGED
package/lib/utils/jwt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SignatureKey, c as SignatureAlgorithm, i as AcrylJsonWebKey, n as VerifyOptions, r as VerifyOptionsWithAlg, s as AsymmetricAlgorithm, t as TokenHeader } from "../jwt-
|
|
1
|
+
import { a as SignatureKey, c as SignatureAlgorithm, i as AcrylJsonWebKey, n as VerifyOptions, r as VerifyOptionsWithAlg, s as AsymmetricAlgorithm, t as TokenHeader } from "../jwt-BA65QhnJ.js";
|
|
2
2
|
import { t as JWTPayload } from "../types-DR95J00T.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../plugins/acryl-router/src/core/utils/jwt/index.d.ts
|
package/lib/utils/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { BinaryType, BufferSource, CloseEvent, CryptoKey, Equal, Expect, HasRequiredKeys, IfAnyThenEmptyObject, InterfaceToType, InvalidJSONValue, IsAny, JSONArray, JSONObject, JSONParsed, JSONPrimitive, JSONValue, JsonWebKey, MessageEvent, NotEqual, RemoveBlankRecord, RequiredKeysOf, Simplify, SimplifyDeepArray, StringLiteralUnion, UnionToIntersection };
|
|
1
|
+
import { C as Simplify, E as UnionToIntersection, S as RequiredKeysOf, T as StringLiteralUnion, _ as JSONValue, a as Equal, b as NotEqual, c as HeadersInit, d as InvalidJSONValue, f as IsAny, g as JSONPrimitive, h as JSONParsed, i as CryptoKey, l as IfAnyThenEmptyObject, m as JSONObject, n as BufferSource, o as Expect, p as JSONArray, r as CloseEvent, s as HasRequiredKeys, t as BinaryType, u as InterfaceToType, v as JsonWebKey, w as SimplifyDeepArray, x as RemoveBlankRecord, y as MessageEvent } from "../types-D9DEXMjE.js";
|
|
2
|
+
export { BinaryType, BufferSource, CloseEvent, CryptoKey, Equal, Expect, HasRequiredKeys, HeadersInit, IfAnyThenEmptyObject, InterfaceToType, InvalidJSONValue, IsAny, JSONArray, JSONObject, JSONParsed, JSONPrimitive, JSONValue, JsonWebKey, MessageEvent, NotEqual, RemoveBlankRecord, RequiredKeysOf, Simplify, SimplifyDeepArray, StringLiteralUnion, UnionToIntersection };
|
package/lib/validator.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as MiddlewareHandler, W as ParsedFormValue, X as TypedResponse, Z as ValidationTargets, _ as Env, t as Context, w as FormValue } from "./context-
|
|
2
|
-
import {
|
|
1
|
+
import { I as MiddlewareHandler, W as ParsedFormValue, X as TypedResponse, Z as ValidationTargets, _ as Env, t as Context, w as FormValue } from "./context-B5Y1lLha.js";
|
|
2
|
+
import { E as UnionToIntersection } from "./types-D9DEXMjE.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../plugins/acryl-router/src/core/validator/utils.d.ts
|
|
5
5
|
/**
|
package/lib/ws.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as WSEvents, c as WebSocketHelperDefineContext, d as defineWebSocketHelper, i as WSContextInit, l as WebSocketHelperDefineHandler, n as UpgradeWebSocket, o as WSMessageReceive, r as WSContext, s as WSReadyState, t as SendOptions, u as createWSMessageEvent } from "./index-
|
|
1
|
+
import { a as WSEvents, c as WebSocketHelperDefineContext, d as defineWebSocketHelper, i as WSContextInit, l as WebSocketHelperDefineHandler, n as UpgradeWebSocket, o as WSMessageReceive, r as WSContext, s as WSReadyState, t as SendOptions, u as createWSMessageEvent } from "./index-Kqou8Fjh.js";
|
|
2
2
|
export { SendOptions, UpgradeWebSocket, WSContext, WSContextInit, WSEvents, WSMessageReceive, WSReadyState, WebSocketHelperDefineContext, WebSocketHelperDefineHandler, createWSMessageEvent, defineWebSocketHelper };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "acrylblends",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "The Acryl web framework (import { Acryl } from \"acrylblends\") and the acrylblends command that scaffolds Cordis apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,6 +30,14 @@
|
|
|
30
30
|
"types": "./lib/http-exception.d.ts",
|
|
31
31
|
"default": "./lib/http-exception.js"
|
|
32
32
|
},
|
|
33
|
+
"./tiny": {
|
|
34
|
+
"types": "./lib/tiny.d.ts",
|
|
35
|
+
"default": "./lib/tiny.js"
|
|
36
|
+
},
|
|
37
|
+
"./quick": {
|
|
38
|
+
"types": "./lib/quick.d.ts",
|
|
39
|
+
"default": "./lib/quick.js"
|
|
40
|
+
},
|
|
33
41
|
"./basic-auth": {
|
|
34
42
|
"types": "./lib/basic-auth.d.ts",
|
|
35
43
|
"default": "./lib/basic-auth.js"
|
|
@@ -42,6 +50,10 @@
|
|
|
42
50
|
"types": "./lib/body-limit.d.ts",
|
|
43
51
|
"default": "./lib/body-limit.js"
|
|
44
52
|
},
|
|
53
|
+
"./cache": {
|
|
54
|
+
"types": "./lib/cache.d.ts",
|
|
55
|
+
"default": "./lib/cache.js"
|
|
56
|
+
},
|
|
45
57
|
"./combine": {
|
|
46
58
|
"types": "./lib/combine.d.ts",
|
|
47
59
|
"default": "./lib/combine.js"
|
|
@@ -94,6 +106,10 @@
|
|
|
94
106
|
"types": "./lib/method-override.d.ts",
|
|
95
107
|
"default": "./lib/method-override.js"
|
|
96
108
|
},
|
|
109
|
+
"./mount": {
|
|
110
|
+
"types": "./lib/mount.d.ts",
|
|
111
|
+
"default": "./lib/mount.js"
|
|
112
|
+
},
|
|
97
113
|
"./powered-by": {
|
|
98
114
|
"types": "./lib/powered-by.d.ts",
|
|
99
115
|
"default": "./lib/powered-by.js"
|
|
@@ -138,6 +154,10 @@
|
|
|
138
154
|
"types": "./lib/cookie.d.ts",
|
|
139
155
|
"default": "./lib/cookie.js"
|
|
140
156
|
},
|
|
157
|
+
"./dev": {
|
|
158
|
+
"types": "./lib/dev.d.ts",
|
|
159
|
+
"default": "./lib/dev.js"
|
|
160
|
+
},
|
|
141
161
|
"./factory": {
|
|
142
162
|
"types": "./lib/factory.d.ts",
|
|
143
163
|
"default": "./lib/factory.js"
|
|
@@ -146,6 +166,10 @@
|
|
|
146
166
|
"types": "./lib/html.d.ts",
|
|
147
167
|
"default": "./lib/html.js"
|
|
148
168
|
},
|
|
169
|
+
"./proxy": {
|
|
170
|
+
"types": "./lib/proxy.d.ts",
|
|
171
|
+
"default": "./lib/proxy.js"
|
|
172
|
+
},
|
|
149
173
|
"./route": {
|
|
150
174
|
"types": "./lib/route.d.ts",
|
|
151
175
|
"default": "./lib/route.js"
|