@zuplo/cli 7.2.4 → 7.3.1
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/node_modules/@posthog/core/dist/error-tracking/parsers/base.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/error-tracking/parsers/base.js +2 -1
- package/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs +2 -1
- package/node_modules/@posthog/core/package.json +2 -2
- package/node_modules/@posthog/core/src/error-tracking/parsers/base.spec.ts +33 -0
- package/node_modules/@posthog/core/src/error-tracking/parsers/base.ts +9 -1
- package/node_modules/@posthog/types/dist/posthog-config.d.ts +12 -6
- package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/posthog-config.ts +20 -6
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/out/esm/chunk-6AFSG5YF.js +26 -0
- package/node_modules/@zuplo/otel/out/esm/chunk-6AFSG5YF.js.map +1 -0
- package/node_modules/@zuplo/otel/out/esm/index.js +1 -1
- package/node_modules/@zuplo/otel/out/types/index.d.ts +28 -5
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/hono/dist/cjs/client/utils.js +1 -1
- package/node_modules/hono/dist/cjs/context.js +4 -0
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/etag/digest.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +43 -67
- package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/client/utils.js +1 -1
- package/node_modules/hono/dist/context.js +4 -0
- package/node_modules/hono/dist/middleware/cors/index.js +1 -1
- package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/middleware/etag/digest.js +1 -1
- package/node_modules/hono/dist/middleware/etag/index.js +2 -2
- package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/router/trie-router/node.js +43 -67
- package/node_modules/hono/dist/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/types/context.d.ts +4 -0
- package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
- package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
- package/node_modules/hono/dist/utils/ipaddr.js +5 -3
- package/node_modules/hono/package.json +1 -1
- package/package.json +6 -6
- package/node_modules/@zuplo/otel/out/esm/chunk-AHNBOCFU.js +0 -26
- package/node_modules/@zuplo/otel/out/esm/chunk-AHNBOCFU.js.map +0 -1
|
@@ -27,12 +27,19 @@ export declare class BatchTraceSpanProcessor implements TraceFlushableSpanProces
|
|
|
27
27
|
readonly exporter: SpanExporter;
|
|
28
28
|
private traces;
|
|
29
29
|
private totalEvicted;
|
|
30
|
+
/**
|
|
31
|
+
* The key each span was filed under at `onStart`. `onEnd` receives only the
|
|
32
|
+
* span, and the key cannot be recomputed from it: the invocation lives in the
|
|
33
|
+
* context, which is not available there. A WeakMap keeps this from becoming a
|
|
34
|
+
* second thing to clean up — an entry disappears with the span itself.
|
|
35
|
+
*/
|
|
36
|
+
private spanTraceKeys;
|
|
30
37
|
constructor(exporter: SpanExporter);
|
|
31
|
-
getTraceState(
|
|
38
|
+
getTraceState(key: TraceStateKey): TraceState;
|
|
32
39
|
private evictOverflow;
|
|
33
40
|
onStart(span: Span, parentContext: Context): void;
|
|
34
41
|
onEnd(span: ReadableSpan): void;
|
|
35
|
-
forceFlush(
|
|
42
|
+
forceFlush(key?: TraceStateKey): Promise<void>;
|
|
36
43
|
shutdown(): Promise<void>;
|
|
37
44
|
}
|
|
38
45
|
|
|
@@ -372,11 +379,20 @@ declare interface TraceConfigSpanProcessors extends TraceConfigBase {
|
|
|
372
379
|
}
|
|
373
380
|
|
|
374
381
|
declare type TraceFlushableSpanProcessor = SpanProcessor & {
|
|
375
|
-
|
|
382
|
+
/**
|
|
383
|
+
* Flushes one trace's buffered spans, or all of them when no key is given.
|
|
384
|
+
*
|
|
385
|
+
* The key is opaque and must be built with `traceStateKey(traceId,
|
|
386
|
+
* invocationId)` — its encoding is an implementation detail of
|
|
387
|
+
* `invocation.ts` and may change. Passing a bare traceId is correct only for
|
|
388
|
+
* spans started outside a handler run (background work, `root: true` outside
|
|
389
|
+
* the request context), which is what that helper returns when there is no
|
|
390
|
+
* invocation in context. See `invocation.ts` for why traceId alone is not
|
|
391
|
+
* sufficient in general.
|
|
392
|
+
*/
|
|
393
|
+
forceFlush: (key?: string) => Promise<void>;
|
|
376
394
|
};
|
|
377
395
|
|
|
378
|
-
declare type TraceId = string;
|
|
379
|
-
|
|
380
396
|
declare class TraceState {
|
|
381
397
|
private unexportedSpans;
|
|
382
398
|
private inprogressSpans;
|
|
@@ -395,6 +411,13 @@ declare class TraceState {
|
|
|
395
411
|
private exportSpans;
|
|
396
412
|
}
|
|
397
413
|
|
|
414
|
+
/**
|
|
415
|
+
* Key under which a trace's buffered state is held: the traceId plus the
|
|
416
|
+
* invocation that produced it, so concurrent requests sharing an inbound
|
|
417
|
+
* `traceparent` get one buffer each. See `invocation.ts`.
|
|
418
|
+
*/
|
|
419
|
+
declare type TraceStateKey = string;
|
|
420
|
+
|
|
398
421
|
/**
|
|
399
422
|
* Span exporter that ships spans to the Zuplo-managed trace ingest, where they
|
|
400
423
|
* become queryable in the Zuplo portal. Add it like any other exporter — wrap
|
|
@@ -37,7 +37,7 @@ const mergePath = (base, path) => {
|
|
|
37
37
|
const replaceUrlParam = (urlString, params) => {
|
|
38
38
|
for (const [k, v] of Object.entries(params)) {
|
|
39
39
|
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
|
|
40
|
-
urlString = urlString.replace(reg, v ? `/${v}` : "");
|
|
40
|
+
urlString = urlString.replace(reg, () => v ? `/${v}` : "");
|
|
41
41
|
}
|
|
42
42
|
return urlString;
|
|
43
43
|
};
|
|
@@ -224,6 +224,10 @@ class Context {
|
|
|
224
224
|
* c.header('X-Message', 'Hello!')
|
|
225
225
|
* c.header('Content-Type', 'text/plain')
|
|
226
226
|
*
|
|
227
|
+
* // Append multiple headers using the append option (e.g. Vary)
|
|
228
|
+
* c.header('Vary', 'Accept-Encoding', { append: true })
|
|
229
|
+
* c.header('Vary', 'User-Agent', { append: true })
|
|
230
|
+
*
|
|
227
231
|
* return c.body('Thank you for coming')
|
|
228
232
|
* })
|
|
229
233
|
* ```
|
|
@@ -69,7 +69,7 @@ const cors = (options) => {
|
|
|
69
69
|
}
|
|
70
70
|
if (c.req.method === "OPTIONS") {
|
|
71
71
|
if (opts.origin !== "*") {
|
|
72
|
-
|
|
72
|
+
c.res.headers.append("Vary", "Origin");
|
|
73
73
|
}
|
|
74
74
|
if (opts.maxAge != null) {
|
|
75
75
|
set("Access-Control-Max-Age", opts.maxAge.toString());
|
|
@@ -23,7 +23,7 @@ module.exports = __toCommonJS(csrf_exports);
|
|
|
23
23
|
var import_http_exception = require("../../http-exception");
|
|
24
24
|
const secFetchSiteValues = ["same-origin", "same-site", "none", "cross-site"];
|
|
25
25
|
const isSecFetchSite = (value) => secFetchSiteValues.includes(value);
|
|
26
|
-
const isSafeMethodRe = /^(GET|HEAD)$/;
|
|
26
|
+
const isSafeMethodRe = /^(GET|HEAD|OPTIONS)$/;
|
|
27
27
|
const isRequestedByFormElementRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b/i;
|
|
28
28
|
const csrf = (options) => {
|
|
29
29
|
const originHandler = ((optsOrigin) => {
|
|
@@ -59,7 +59,7 @@ const generateDigest = async (stream, generator) => {
|
|
|
59
59
|
const requiredLength = chunkLength + remaining;
|
|
60
60
|
if (requiredLength < CHUNK_SIZE) {
|
|
61
61
|
if (!chunk) {
|
|
62
|
-
chunk = value.
|
|
62
|
+
chunk = value.slice(offset);
|
|
63
63
|
} else {
|
|
64
64
|
if (chunk.byteLength < requiredLength) {
|
|
65
65
|
const nextChunk = new Uint8Array(
|
|
@@ -82,11 +82,11 @@ const etag = (options) => {
|
|
|
82
82
|
ETag: etag3
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
-
c.res.headers.
|
|
85
|
+
for (const key of Array.from(c.res.headers.keys())) {
|
|
86
86
|
if (retainedHeaders.indexOf(key.toLowerCase()) === -1) {
|
|
87
87
|
c.res.headers.delete(key);
|
|
88
88
|
}
|
|
89
|
-
}
|
|
89
|
+
}
|
|
90
90
|
} else {
|
|
91
91
|
c.res.headers.set("ETag", etag3);
|
|
92
92
|
}
|
|
@@ -20,12 +20,14 @@ __export(pretty_json_exports, {
|
|
|
20
20
|
prettyJSON: () => prettyJSON
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(pretty_json_exports);
|
|
23
|
+
const jsonContentTypeRegex = /^application\/(?:[a-z0-9._-]+\+)?json(?=$|[;\s])/i;
|
|
23
24
|
const prettyJSON = (options) => {
|
|
24
25
|
const targetQuery = options?.query ?? "pretty";
|
|
25
26
|
return async function prettyJSON2(c, next) {
|
|
26
27
|
const pretty = options?.force || c.req.query(targetQuery) || c.req.query(targetQuery) === "";
|
|
27
28
|
await next();
|
|
28
|
-
|
|
29
|
+
const contentType = c.res.headers.get("Content-Type");
|
|
30
|
+
if (pretty && contentType && jsonContentTypeRegex.test(contentType)) {
|
|
29
31
|
const obj = await c.res.json();
|
|
30
32
|
c.res = new Response(JSON.stringify(obj, null, options?.space ?? 2), c.res);
|
|
31
33
|
}
|
|
@@ -50,7 +50,8 @@ class LinearRouter {
|
|
|
50
50
|
}
|
|
51
51
|
} else if (hasStar && !hasLabel) {
|
|
52
52
|
const endsWithStar = routePath.charCodeAt(routePath.length - 1) === 42;
|
|
53
|
-
const
|
|
53
|
+
const endsWithSlashStar = routePath.endsWith("/*");
|
|
54
|
+
const parts = (endsWithStar ? routePath.slice(0, endsWithSlashStar ? -2 : -1) : routePath).split(splitByStarRe);
|
|
54
55
|
const lastIndex = parts.length - 1;
|
|
55
56
|
for (let j = 0, pos = 0, len2 = parts.length; j < len2; j++) {
|
|
56
57
|
const part = parts[j];
|
|
@@ -60,7 +61,11 @@ class LinearRouter {
|
|
|
60
61
|
}
|
|
61
62
|
pos += part.length;
|
|
62
63
|
if (j === lastIndex) {
|
|
63
|
-
if (
|
|
64
|
+
if (endsWithSlashStar) {
|
|
65
|
+
if (pos !== path.length && path.charCodeAt(pos) !== 47) {
|
|
66
|
+
continue ROUTES_LOOP;
|
|
67
|
+
}
|
|
68
|
+
} else if (!endsWithStar && pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) {
|
|
64
69
|
continue ROUTES_LOOP;
|
|
65
70
|
}
|
|
66
71
|
} else {
|
|
@@ -26,10 +26,8 @@ class PatternRouter {
|
|
|
26
26
|
name = "PatternRouter";
|
|
27
27
|
#routes = [];
|
|
28
28
|
add(method, path, handler) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
path = path.slice(0, -2);
|
|
32
|
-
}
|
|
29
|
+
const suffix = path.endsWith("/*") ? "(?:$|/)" : path.endsWith("*") ? "" : "/?$";
|
|
30
|
+
path = path.replace(/\*$/, "");
|
|
33
31
|
if (path.at(-1) === "?") {
|
|
34
32
|
path = path.slice(0, -1);
|
|
35
33
|
this.add(method, path.replace(/\/[^/]+$/, ""), handler);
|
|
@@ -41,11 +39,7 @@ class PatternRouter {
|
|
|
41
39
|
}
|
|
42
40
|
);
|
|
43
41
|
try {
|
|
44
|
-
this.#routes.push([
|
|
45
|
-
new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`),
|
|
46
|
-
method,
|
|
47
|
-
handler
|
|
48
|
-
]);
|
|
42
|
+
this.#routes.push([new RegExp(`^${parts.join("")}${suffix}`), method, handler]);
|
|
49
43
|
} catch {
|
|
50
44
|
throw new import_router.UnsupportedPathError();
|
|
51
45
|
}
|
|
@@ -23,76 +23,51 @@ module.exports = __toCommonJS(node_exports);
|
|
|
23
23
|
var import_router = require("../../router");
|
|
24
24
|
var import_url = require("../../utils/url");
|
|
25
25
|
const emptyParams = /* @__PURE__ */ Object.create(null);
|
|
26
|
-
|
|
27
|
-
for (const _ in children) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
};
|
|
26
|
+
let order = 0;
|
|
32
27
|
class Node {
|
|
33
|
-
#methods;
|
|
34
|
-
#children;
|
|
35
|
-
#patterns;
|
|
36
|
-
#
|
|
28
|
+
#methods = [];
|
|
29
|
+
#children = /* @__PURE__ */ Object.create(null);
|
|
30
|
+
#patterns = [];
|
|
31
|
+
#pattern;
|
|
37
32
|
#params = emptyParams;
|
|
38
|
-
constructor(method, handler, children) {
|
|
39
|
-
this.#children = children || /* @__PURE__ */ Object.create(null);
|
|
40
|
-
this.#methods = [];
|
|
41
|
-
if (method && handler) {
|
|
42
|
-
const m = /* @__PURE__ */ Object.create(null);
|
|
43
|
-
m[method] = { handler, possibleKeys: [], score: 0 };
|
|
44
|
-
this.#methods = [m];
|
|
45
|
-
}
|
|
46
|
-
this.#patterns = [];
|
|
47
|
-
}
|
|
48
33
|
insert(method, path, handler) {
|
|
49
|
-
this.#order = ++this.#order;
|
|
50
34
|
let curNode = this;
|
|
51
35
|
const parts = (0, import_url.splitRoutingPath)(path);
|
|
52
|
-
const possibleKeys =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const nextP = parts[i
|
|
56
|
-
const pattern = (0, import_url.getPattern)(p, nextP);
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
continue;
|
|
36
|
+
const possibleKeys = /* @__PURE__ */ new Set();
|
|
37
|
+
let i = 0;
|
|
38
|
+
for (const p of parts) {
|
|
39
|
+
const nextP = parts[++i];
|
|
40
|
+
const pattern = (0, import_url.getPattern)(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
|
|
41
|
+
const isParam = Array.isArray(pattern);
|
|
42
|
+
const key = isParam ? pattern[0] : pattern || p;
|
|
43
|
+
const child = curNode.#children[key] ||= new Node();
|
|
44
|
+
if (pattern && !child.#pattern) {
|
|
45
|
+
child.#pattern = pattern;
|
|
46
|
+
curNode.#patterns.push(child);
|
|
64
47
|
}
|
|
65
|
-
curNode
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
possibleKeys.push(pattern[1]);
|
|
48
|
+
curNode = child;
|
|
49
|
+
if (isParam) {
|
|
50
|
+
possibleKeys.add(pattern[1]);
|
|
69
51
|
}
|
|
70
|
-
curNode = curNode.#children[key];
|
|
71
52
|
}
|
|
72
53
|
curNode.#methods.push({
|
|
73
54
|
[method]: {
|
|
74
55
|
handler,
|
|
75
|
-
possibleKeys: possibleKeys
|
|
76
|
-
score:
|
|
56
|
+
possibleKeys: [...possibleKeys],
|
|
57
|
+
score: ++order
|
|
77
58
|
}
|
|
78
59
|
});
|
|
79
|
-
return curNode;
|
|
80
60
|
}
|
|
81
61
|
#pushHandlerSets(handlerSets, node, method, nodeParams, params) {
|
|
82
62
|
for (let i = 0, len = node.#methods.length; i < len; i++) {
|
|
83
63
|
const m = node.#methods[i];
|
|
84
64
|
const handlerSet = m[method] || m[import_router.METHOD_NAME_ALL];
|
|
85
|
-
|
|
86
|
-
if (handlerSet !== void 0) {
|
|
65
|
+
if (handlerSet) {
|
|
87
66
|
handlerSet.params = /* @__PURE__ */ Object.create(null);
|
|
88
67
|
handlerSets.push(handlerSet);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const processed = processedSet[handlerSet.score];
|
|
93
|
-
handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key];
|
|
94
|
-
processedSet[handlerSet.score] = true;
|
|
95
|
-
}
|
|
68
|
+
for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
|
|
69
|
+
const key = handlerSet.possibleKeys[i2];
|
|
70
|
+
handlerSet.params[key] = params?.[key] && !i2 ? params[key] : nodeParams[key] ?? params?.[key];
|
|
96
71
|
}
|
|
97
72
|
}
|
|
98
73
|
}
|
|
@@ -124,33 +99,33 @@ class Node {
|
|
|
124
99
|
tempNodes.push(nextNode);
|
|
125
100
|
}
|
|
126
101
|
}
|
|
127
|
-
for (
|
|
128
|
-
const pattern =
|
|
102
|
+
for (const child of node.#patterns) {
|
|
103
|
+
const pattern = child.#pattern;
|
|
129
104
|
const params = node.#params === emptyParams ? {} : { ...node.#params };
|
|
130
|
-
if (pattern === "
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
105
|
+
if (typeof pattern === "string") {
|
|
106
|
+
if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
|
|
107
|
+
this.#pushHandlerSets(handlerSets, child, method, node.#params);
|
|
108
|
+
if (pattern === "*") {
|
|
109
|
+
child.#params = params;
|
|
110
|
+
tempNodes.push(child);
|
|
111
|
+
}
|
|
136
112
|
}
|
|
137
113
|
continue;
|
|
138
114
|
}
|
|
139
|
-
const [
|
|
140
|
-
if (!part &&
|
|
115
|
+
const [, name, matcher] = pattern;
|
|
116
|
+
if (!part && matcher === true) {
|
|
141
117
|
continue;
|
|
142
118
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
partOffsets = new Array(len);
|
|
119
|
+
if (matcher !== true) {
|
|
120
|
+
if (!partOffsets) {
|
|
121
|
+
partOffsets = [];
|
|
147
122
|
let offset = path[0] === "/" ? 1 : 0;
|
|
148
123
|
for (let p = 0; p < len; p++) {
|
|
149
124
|
partOffsets[p] = offset;
|
|
150
125
|
offset += parts[p].length + 1;
|
|
151
126
|
}
|
|
152
127
|
}
|
|
153
|
-
const restPathString = path.
|
|
128
|
+
const restPathString = path.slice(partOffsets[i]);
|
|
154
129
|
const m = matcher.exec(restPathString);
|
|
155
130
|
if (m) {
|
|
156
131
|
params[name] = m[0];
|
|
@@ -164,11 +139,12 @@ class Node {
|
|
|
164
139
|
params
|
|
165
140
|
);
|
|
166
141
|
}
|
|
167
|
-
|
|
142
|
+
for (const _ in child.#children) {
|
|
168
143
|
child.#params = params;
|
|
169
144
|
const componentCount = m[0].match(/\//g)?.length ?? 0;
|
|
170
145
|
const targetCurNodes = curNodesQueue[componentCount] ||= [];
|
|
171
146
|
targetCurNodes.push(child);
|
|
147
|
+
break;
|
|
172
148
|
}
|
|
173
149
|
continue;
|
|
174
150
|
}
|
|
@@ -196,7 +172,7 @@ class Node {
|
|
|
196
172
|
const shifted = curNodesQueue.shift();
|
|
197
173
|
curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
|
|
198
174
|
}
|
|
199
|
-
if (handlerSets
|
|
175
|
+
if (handlerSets[1]) {
|
|
200
176
|
handlerSets.sort((a, b) => {
|
|
201
177
|
return a.score - b.score;
|
|
202
178
|
});
|
|
@@ -24,19 +24,11 @@ var import_url = require("../../utils/url");
|
|
|
24
24
|
var import_node = require("./node");
|
|
25
25
|
class TrieRouter {
|
|
26
26
|
name = "TrieRouter";
|
|
27
|
-
#node;
|
|
28
|
-
constructor() {
|
|
29
|
-
this.#node = new import_node.Node();
|
|
30
|
-
}
|
|
27
|
+
#node = new import_node.Node();
|
|
31
28
|
add(method, path, handler) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
for (let i = 0, len = results.length; i < len; i++) {
|
|
35
|
-
this.#node.insert(method, results[i], handler);
|
|
36
|
-
}
|
|
37
|
-
return;
|
|
29
|
+
for (const result of (0, import_url.checkOptionalParameter)(path) || [path]) {
|
|
30
|
+
this.#node.insert(method, result, handler);
|
|
38
31
|
}
|
|
39
|
-
this.#node.insert(method, path, handler);
|
|
40
32
|
}
|
|
41
33
|
match(method, path) {
|
|
42
34
|
return this.#node.search(method, path);
|
|
@@ -30,12 +30,14 @@ __export(ipaddr_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(ipaddr_exports);
|
|
31
31
|
const expandIPv6 = (ipV6) => {
|
|
32
32
|
const sections = ipV6.split(":");
|
|
33
|
-
|
|
33
|
+
const lastSection = sections.at(-1);
|
|
34
|
+
if (IPV4_REGEX.test(lastSection)) {
|
|
35
|
+
const octets = lastSection.split(".").map(Number);
|
|
34
36
|
sections.splice(
|
|
35
37
|
-1,
|
|
36
38
|
1,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
(octets[0] << 8 | octets[1]).toString(16),
|
|
40
|
+
(octets[2] << 8 | octets[3]).toString(16)
|
|
39
41
|
);
|
|
40
42
|
}
|
|
41
43
|
for (let i = 0; i < sections.length; i++) {
|
|
@@ -9,7 +9,7 @@ var mergePath = (base, path) => {
|
|
|
9
9
|
var replaceUrlParam = (urlString, params) => {
|
|
10
10
|
for (const [k, v] of Object.entries(params)) {
|
|
11
11
|
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
|
|
12
|
-
urlString = urlString.replace(reg, v ? `/${v}` : "");
|
|
12
|
+
urlString = urlString.replace(reg, () => v ? `/${v}` : "");
|
|
13
13
|
}
|
|
14
14
|
return urlString;
|
|
15
15
|
};
|
|
@@ -202,6 +202,10 @@ var Context = class {
|
|
|
202
202
|
* c.header('X-Message', 'Hello!')
|
|
203
203
|
* c.header('Content-Type', 'text/plain')
|
|
204
204
|
*
|
|
205
|
+
* // Append multiple headers using the append option (e.g. Vary)
|
|
206
|
+
* c.header('Vary', 'Accept-Encoding', { append: true })
|
|
207
|
+
* c.header('Vary', 'User-Agent', { append: true })
|
|
208
|
+
*
|
|
205
209
|
* return c.body('Thank you for coming')
|
|
206
210
|
* })
|
|
207
211
|
* ```
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { HTTPException } from "../../http-exception.js";
|
|
3
3
|
var secFetchSiteValues = ["same-origin", "same-site", "none", "cross-site"];
|
|
4
4
|
var isSecFetchSite = (value) => secFetchSiteValues.includes(value);
|
|
5
|
-
var isSafeMethodRe = /^(GET|HEAD)$/;
|
|
5
|
+
var isSafeMethodRe = /^(GET|HEAD|OPTIONS)$/;
|
|
6
6
|
var isRequestedByFormElementRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b/i;
|
|
7
7
|
var csrf = (options) => {
|
|
8
8
|
const originHandler = ((optsOrigin) => {
|
|
@@ -38,7 +38,7 @@ var generateDigest = async (stream, generator) => {
|
|
|
38
38
|
const requiredLength = chunkLength + remaining;
|
|
39
39
|
if (requiredLength < CHUNK_SIZE) {
|
|
40
40
|
if (!chunk) {
|
|
41
|
-
chunk = value.
|
|
41
|
+
chunk = value.slice(offset);
|
|
42
42
|
} else {
|
|
43
43
|
if (chunk.byteLength < requiredLength) {
|
|
44
44
|
const nextChunk = new Uint8Array(
|
|
@@ -60,11 +60,11 @@ var etag = (options) => {
|
|
|
60
60
|
ETag: etag3
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
c.res.headers.
|
|
63
|
+
for (const key of Array.from(c.res.headers.keys())) {
|
|
64
64
|
if (retainedHeaders.indexOf(key.toLowerCase()) === -1) {
|
|
65
65
|
c.res.headers.delete(key);
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|
|
68
68
|
} else {
|
|
69
69
|
c.res.headers.set("ETag", etag3);
|
|
70
70
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// src/middleware/pretty-json/index.ts
|
|
2
|
+
var jsonContentTypeRegex = /^application\/(?:[a-z0-9._-]+\+)?json(?=$|[;\s])/i;
|
|
2
3
|
var prettyJSON = (options) => {
|
|
3
4
|
const targetQuery = options?.query ?? "pretty";
|
|
4
5
|
return async function prettyJSON2(c, next) {
|
|
5
6
|
const pretty = options?.force || c.req.query(targetQuery) || c.req.query(targetQuery) === "";
|
|
6
7
|
await next();
|
|
7
|
-
|
|
8
|
+
const contentType = c.res.headers.get("Content-Type");
|
|
9
|
+
if (pretty && contentType && jsonContentTypeRegex.test(contentType)) {
|
|
8
10
|
const obj = await c.res.json();
|
|
9
11
|
c.res = new Response(JSON.stringify(obj, null, options?.space ?? 2), c.res);
|
|
10
12
|
}
|
|
@@ -29,7 +29,8 @@ var LinearRouter = class {
|
|
|
29
29
|
}
|
|
30
30
|
} else if (hasStar && !hasLabel) {
|
|
31
31
|
const endsWithStar = routePath.charCodeAt(routePath.length - 1) === 42;
|
|
32
|
-
const
|
|
32
|
+
const endsWithSlashStar = routePath.endsWith("/*");
|
|
33
|
+
const parts = (endsWithStar ? routePath.slice(0, endsWithSlashStar ? -2 : -1) : routePath).split(splitByStarRe);
|
|
33
34
|
const lastIndex = parts.length - 1;
|
|
34
35
|
for (let j = 0, pos = 0, len2 = parts.length; j < len2; j++) {
|
|
35
36
|
const part = parts[j];
|
|
@@ -39,7 +40,11 @@ var LinearRouter = class {
|
|
|
39
40
|
}
|
|
40
41
|
pos += part.length;
|
|
41
42
|
if (j === lastIndex) {
|
|
42
|
-
if (
|
|
43
|
+
if (endsWithSlashStar) {
|
|
44
|
+
if (pos !== path.length && path.charCodeAt(pos) !== 47) {
|
|
45
|
+
continue ROUTES_LOOP;
|
|
46
|
+
}
|
|
47
|
+
} else if (!endsWithStar && pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) {
|
|
43
48
|
continue ROUTES_LOOP;
|
|
44
49
|
}
|
|
45
50
|
} else {
|
|
@@ -5,10 +5,8 @@ var PatternRouter = class {
|
|
|
5
5
|
name = "PatternRouter";
|
|
6
6
|
#routes = [];
|
|
7
7
|
add(method, path, handler) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
path = path.slice(0, -2);
|
|
11
|
-
}
|
|
8
|
+
const suffix = path.endsWith("/*") ? "(?:$|/)" : path.endsWith("*") ? "" : "/?$";
|
|
9
|
+
path = path.replace(/\*$/, "");
|
|
12
10
|
if (path.at(-1) === "?") {
|
|
13
11
|
path = path.slice(0, -1);
|
|
14
12
|
this.add(method, path.replace(/\/[^/]+$/, ""), handler);
|
|
@@ -20,11 +18,7 @@ var PatternRouter = class {
|
|
|
20
18
|
}
|
|
21
19
|
);
|
|
22
20
|
try {
|
|
23
|
-
this.#routes.push([
|
|
24
|
-
new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`),
|
|
25
|
-
method,
|
|
26
|
-
handler
|
|
27
|
-
]);
|
|
21
|
+
this.#routes.push([new RegExp(`^${parts.join("")}${suffix}`), method, handler]);
|
|
28
22
|
} catch {
|
|
29
23
|
throw new UnsupportedPathError();
|
|
30
24
|
}
|