hono 3.2.7 → 3.3.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.
@@ -0,0 +1,58 @@
1
+ // src/adapter/lambda-edge/handler.ts
2
+ import crypto from "crypto";
3
+ import { encodeBase64 } from "../../utils/encode.js";
4
+ globalThis.crypto ?? (globalThis.crypto = crypto);
5
+ var handle = (app) => {
6
+ return async (event, context, callback) => {
7
+ const req = createRequest(event);
8
+ const res = await app.fetch(req, {
9
+ event,
10
+ context,
11
+ callback,
12
+ request: event.Records[0].cf.request
13
+ });
14
+ return createResult(res);
15
+ };
16
+ };
17
+ var createResult = async (res) => {
18
+ const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || "");
19
+ const body = isBase64Encoded ? encodeBase64(await res.arrayBuffer()) : await res.text();
20
+ const headers = {};
21
+ res.headers.forEach((value, key) => {
22
+ headers[key.toLowerCase()] = [{ key: key.toLowerCase(), value }];
23
+ });
24
+ return {
25
+ status: res.status.toString(),
26
+ headers,
27
+ body
28
+ };
29
+ };
30
+ var createRequest = (event) => {
31
+ const queryString = extractQueryString(event);
32
+ const urlPath = `https://${event.Records[0].cf.config.distributionDomainName}${event.Records[0].cf.request.uri}`;
33
+ const url = queryString ? `${urlPath}?${queryString}` : urlPath;
34
+ const headers = new Headers();
35
+ for (const [k, v] of Object.entries(event.Records[0].cf.request.headers)) {
36
+ v.forEach((header) => headers.set(k, header.value));
37
+ }
38
+ const method = event.Records[0].cf.request.method;
39
+ const requestInit = {
40
+ headers,
41
+ method
42
+ };
43
+ const requestBody = event.Records[0].cf.request.body;
44
+ requestInit.body = requestBody?.encoding === "base64" && requestBody?.data ? atob(requestBody.data) : requestBody?.data;
45
+ return new Request(url, requestInit);
46
+ };
47
+ var extractQueryString = (event) => {
48
+ return event.Records[0].cf.request.querystring;
49
+ };
50
+ var isContentTypeBinary = (contentType) => {
51
+ return !/^(text\/(plain|html|css|javascript|csv).*|application\/(.*json|.*xml).*|image\/svg\+xml)$/.test(
52
+ contentType
53
+ );
54
+ };
55
+ export {
56
+ handle,
57
+ isContentTypeBinary
58
+ };
@@ -0,0 +1,5 @@
1
+ // src/adapter/lambda-edge/index.ts
2
+ import { handle } from "./handler.js";
3
+ export {
4
+ handle
5
+ };
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var handler_exports = {};
26
+ __export(handler_exports, {
27
+ handle: () => handle,
28
+ isContentTypeBinary: () => isContentTypeBinary
29
+ });
30
+ module.exports = __toCommonJS(handler_exports);
31
+ var import_crypto = __toESM(require("crypto"), 1);
32
+ var import_encode = require("../../utils/encode");
33
+ globalThis.crypto ?? (globalThis.crypto = import_crypto.default);
34
+ const handle = (app) => {
35
+ return async (event, context, callback) => {
36
+ const req = createRequest(event);
37
+ const res = await app.fetch(req, {
38
+ event,
39
+ context,
40
+ callback,
41
+ request: event.Records[0].cf.request
42
+ });
43
+ return createResult(res);
44
+ };
45
+ };
46
+ const createResult = async (res) => {
47
+ const isBase64Encoded = isContentTypeBinary(res.headers.get("content-type") || "");
48
+ const body = isBase64Encoded ? (0, import_encode.encodeBase64)(await res.arrayBuffer()) : await res.text();
49
+ const headers = {};
50
+ res.headers.forEach((value, key) => {
51
+ headers[key.toLowerCase()] = [{ key: key.toLowerCase(), value }];
52
+ });
53
+ return {
54
+ status: res.status.toString(),
55
+ headers,
56
+ body
57
+ };
58
+ };
59
+ const createRequest = (event) => {
60
+ const queryString = extractQueryString(event);
61
+ const urlPath = `https://${event.Records[0].cf.config.distributionDomainName}${event.Records[0].cf.request.uri}`;
62
+ const url = queryString ? `${urlPath}?${queryString}` : urlPath;
63
+ const headers = new Headers();
64
+ for (const [k, v] of Object.entries(event.Records[0].cf.request.headers)) {
65
+ v.forEach((header) => headers.set(k, header.value));
66
+ }
67
+ const method = event.Records[0].cf.request.method;
68
+ const requestInit = {
69
+ headers,
70
+ method
71
+ };
72
+ const requestBody = event.Records[0].cf.request.body;
73
+ requestInit.body = requestBody?.encoding === "base64" && requestBody?.data ? atob(requestBody.data) : requestBody?.data;
74
+ return new Request(url, requestInit);
75
+ };
76
+ const extractQueryString = (event) => {
77
+ return event.Records[0].cf.request.querystring;
78
+ };
79
+ const isContentTypeBinary = (contentType) => {
80
+ return !/^(text\/(plain|html|css|javascript|csv).*|application\/(.*json|.*xml).*|image\/svg\+xml)$/.test(
81
+ contentType
82
+ );
83
+ };
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ handle,
87
+ isContentTypeBinary
88
+ });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var lambda_edge_exports = {};
20
+ __export(lambda_edge_exports, {
21
+ handle: () => import_handler.handle
22
+ });
23
+ module.exports = __toCommonJS(lambda_edge_exports);
24
+ var import_handler = require("./handler");
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ handle
28
+ });
@@ -32,7 +32,7 @@ const mergePath = (base, path) => {
32
32
  };
33
33
  const replaceUrlParam = (urlString, params) => {
34
34
  for (const [k, v] of Object.entries(params)) {
35
- const reg = new RegExp("/:" + k);
35
+ const reg = new RegExp("/:" + k + "({[^}]*})?");
36
36
  urlString = urlString.replace(reg, `/${v}`);
37
37
  }
38
38
  return urlString;
@@ -170,8 +170,12 @@ class Hono extends defineDynamicClass() {
170
170
  }
171
171
  const options = optionHandler ? optionHandler(c) : [c.env, executionContext];
172
172
  const optionsArray = Array.isArray(options) ? options : [options];
173
+ const queryStrings = (0, import_url.getQueryStrings)(c.req.url);
173
174
  const res = await applicationHandler(
174
- new Request(new URL(c.req.path.slice(pathPrefixLength) || "/", c.req.url), c.req.raw),
175
+ new Request(
176
+ new URL((c.req.path.slice(pathPrefixLength) || "/") + queryStrings, c.req.url),
177
+ c.req.raw
178
+ ),
175
179
  ...optionsArray
176
180
  );
177
181
  if (res)
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var timing_exports = {};
20
+ __export(timing_exports, {
21
+ endTime: () => endTime,
22
+ setMetric: () => setMetric,
23
+ startTime: () => startTime,
24
+ timing: () => timing
25
+ });
26
+ module.exports = __toCommonJS(timing_exports);
27
+ var import_context = require("../../context");
28
+ const getTime = () => {
29
+ try {
30
+ return performance.now();
31
+ } catch {
32
+ }
33
+ return Date.now();
34
+ };
35
+ const timing = (config) => {
36
+ const options = {
37
+ ...{
38
+ total: true,
39
+ enabled: true,
40
+ totalDescription: "Total Response Time",
41
+ autoEnd: true,
42
+ crossOrigin: false
43
+ },
44
+ ...config
45
+ };
46
+ return async (c, next) => {
47
+ const headers = [];
48
+ const timers = /* @__PURE__ */ new Map();
49
+ c.set("metric", { headers, timers });
50
+ if (options.total) {
51
+ startTime(c, "total", options.totalDescription);
52
+ }
53
+ await next();
54
+ if (options.total) {
55
+ endTime(c, "total");
56
+ }
57
+ if (options.autoEnd) {
58
+ timers.forEach((_, key) => endTime(c, key));
59
+ }
60
+ const enabled = typeof options.enabled === "function" ? options.enabled(c) : options.enabled;
61
+ if (enabled) {
62
+ c.res.headers.append("Server-Timing", headers.join(","));
63
+ if (options.crossOrigin) {
64
+ c.res.headers.append(
65
+ "Timing-Allow-Origin",
66
+ typeof options.crossOrigin === "string" ? options.crossOrigin : "*"
67
+ );
68
+ }
69
+ }
70
+ };
71
+ };
72
+ const setMetric = (c, name, valueDescription, description, precision) => {
73
+ const metrics = c.get("metric");
74
+ if (!metrics) {
75
+ console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");
76
+ return;
77
+ }
78
+ if (typeof valueDescription === "number") {
79
+ const dur = valueDescription.toFixed(precision || 1);
80
+ const metric = description ? `${name};dur=${dur};desc="${description}"` : `${name};dur=${dur}`;
81
+ metrics.headers.push(metric);
82
+ } else {
83
+ const metric = valueDescription ? `${name};desc="${valueDescription}"` : `${name}`;
84
+ metrics.headers.push(metric);
85
+ }
86
+ };
87
+ const startTime = (c, name, description) => {
88
+ const metrics = c.get("metric");
89
+ if (!metrics) {
90
+ console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");
91
+ return;
92
+ }
93
+ metrics.timers.set(name, { description, start: getTime() });
94
+ };
95
+ const endTime = (c, name, precision) => {
96
+ const metrics = c.get("metric");
97
+ if (!metrics) {
98
+ console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");
99
+ return;
100
+ }
101
+ const timer = metrics.timers.get(name);
102
+ if (!timer) {
103
+ console.warn(`Timer "${name}" does not exist!`);
104
+ return;
105
+ }
106
+ const { description, start } = timer;
107
+ const duration = getTime() - start;
108
+ setMetric(c, name, duration, description, precision);
109
+ metrics.timers.delete(name);
110
+ };
111
+ // Annotate the CommonJS export names for ESM import in node:
112
+ 0 && (module.exports = {
113
+ endTime,
114
+ setMetric,
115
+ startTime,
116
+ timing
117
+ });
@@ -25,6 +25,7 @@ __export(url_exports, {
25
25
  getPattern: () => getPattern,
26
26
  getQueryParam: () => getQueryParam,
27
27
  getQueryParams: () => getQueryParams,
28
+ getQueryStrings: () => getQueryStrings,
28
29
  mergePath: () => mergePath,
29
30
  splitPath: () => splitPath,
30
31
  splitRoutingPath: () => splitRoutingPath
@@ -90,6 +91,10 @@ const getPath = (request) => {
90
91
  const queryIndex = url.indexOf("?", 8);
91
92
  return url.slice(url.indexOf("/", 8), queryIndex === -1 ? void 0 : queryIndex);
92
93
  };
94
+ const getQueryStrings = (url) => {
95
+ const queryIndex = url.indexOf("?", 8);
96
+ return queryIndex === -1 ? "" : "?" + url.slice(queryIndex + 1);
97
+ };
93
98
  const getPathNoStrict = (request) => {
94
99
  const result = getPath(request);
95
100
  return result.length > 1 && result[result.length - 1] === "/" ? result.slice(0, -1) : result;
@@ -208,6 +213,7 @@ const decodeURIComponent_ = decodeURIComponent;
208
213
  getPattern,
209
214
  getQueryParam,
210
215
  getQueryParams,
216
+ getQueryStrings,
211
217
  mergePath,
212
218
  splitPath,
213
219
  splitRoutingPath
@@ -7,7 +7,7 @@ var mergePath = (base, path) => {
7
7
  };
8
8
  var replaceUrlParam = (urlString, params) => {
9
9
  for (const [k, v] of Object.entries(params)) {
10
- const reg = new RegExp("/:" + k);
10
+ const reg = new RegExp("/:" + k + "({[^}]*})?");
11
11
  urlString = urlString.replace(reg, `/${v}`);
12
12
  }
13
13
  return urlString;
package/dist/hono-base.js CHANGED
@@ -3,7 +3,7 @@ import { compose } from "./compose.js";
3
3
  import { Context } from "./context.js";
4
4
  import { HTTPException } from "./http-exception.js";
5
5
  import { METHOD_NAME_ALL, METHOD_NAME_ALL_LOWERCASE, METHODS } from "./router.js";
6
- import { getPath, getPathNoStrict, mergePath } from "./utils/url.js";
6
+ import { getPath, getPathNoStrict, getQueryStrings, mergePath } from "./utils/url.js";
7
7
  function defineDynamicClass() {
8
8
  return class {
9
9
  };
@@ -148,8 +148,12 @@ var Hono = class extends defineDynamicClass() {
148
148
  }
149
149
  const options = optionHandler ? optionHandler(c) : [c.env, executionContext];
150
150
  const optionsArray = Array.isArray(options) ? options : [options];
151
+ const queryStrings = getQueryStrings(c.req.url);
151
152
  const res = await applicationHandler(
152
- new Request(new URL(c.req.path.slice(pathPrefixLength) || "/", c.req.url), c.req.raw),
153
+ new Request(
154
+ new URL((c.req.path.slice(pathPrefixLength) || "/") + queryStrings, c.req.url),
155
+ c.req.raw
156
+ ),
153
157
  ...optionsArray
154
158
  );
155
159
  if (res)
@@ -0,0 +1,91 @@
1
+ // src/middleware/timing/index.ts
2
+ import "../../context.js";
3
+ var getTime = () => {
4
+ try {
5
+ return performance.now();
6
+ } catch {
7
+ }
8
+ return Date.now();
9
+ };
10
+ var timing = (config) => {
11
+ const options = {
12
+ ...{
13
+ total: true,
14
+ enabled: true,
15
+ totalDescription: "Total Response Time",
16
+ autoEnd: true,
17
+ crossOrigin: false
18
+ },
19
+ ...config
20
+ };
21
+ return async (c, next) => {
22
+ const headers = [];
23
+ const timers = /* @__PURE__ */ new Map();
24
+ c.set("metric", { headers, timers });
25
+ if (options.total) {
26
+ startTime(c, "total", options.totalDescription);
27
+ }
28
+ await next();
29
+ if (options.total) {
30
+ endTime(c, "total");
31
+ }
32
+ if (options.autoEnd) {
33
+ timers.forEach((_, key) => endTime(c, key));
34
+ }
35
+ const enabled = typeof options.enabled === "function" ? options.enabled(c) : options.enabled;
36
+ if (enabled) {
37
+ c.res.headers.append("Server-Timing", headers.join(","));
38
+ if (options.crossOrigin) {
39
+ c.res.headers.append(
40
+ "Timing-Allow-Origin",
41
+ typeof options.crossOrigin === "string" ? options.crossOrigin : "*"
42
+ );
43
+ }
44
+ }
45
+ };
46
+ };
47
+ var setMetric = (c, name, valueDescription, description, precision) => {
48
+ const metrics = c.get("metric");
49
+ if (!metrics) {
50
+ console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");
51
+ return;
52
+ }
53
+ if (typeof valueDescription === "number") {
54
+ const dur = valueDescription.toFixed(precision || 1);
55
+ const metric = description ? `${name};dur=${dur};desc="${description}"` : `${name};dur=${dur}`;
56
+ metrics.headers.push(metric);
57
+ } else {
58
+ const metric = valueDescription ? `${name};desc="${valueDescription}"` : `${name}`;
59
+ metrics.headers.push(metric);
60
+ }
61
+ };
62
+ var startTime = (c, name, description) => {
63
+ const metrics = c.get("metric");
64
+ if (!metrics) {
65
+ console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");
66
+ return;
67
+ }
68
+ metrics.timers.set(name, { description, start: getTime() });
69
+ };
70
+ var endTime = (c, name, precision) => {
71
+ const metrics = c.get("metric");
72
+ if (!metrics) {
73
+ console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");
74
+ return;
75
+ }
76
+ const timer = metrics.timers.get(name);
77
+ if (!timer) {
78
+ console.warn(`Timer "${name}" does not exist!`);
79
+ return;
80
+ }
81
+ const { description, start } = timer;
82
+ const duration = getTime() - start;
83
+ setMetric(c, name, duration, description, precision);
84
+ metrics.timers.delete(name);
85
+ };
86
+ export {
87
+ endTime,
88
+ setMetric,
89
+ startTime,
90
+ timing
91
+ };
@@ -0,0 +1,72 @@
1
+ import type { Hono } from '../../hono';
2
+ interface CloudFrontHeader {
3
+ key: string;
4
+ value: string;
5
+ }
6
+ interface CloudFrontHeaders {
7
+ [name: string]: CloudFrontHeader[];
8
+ }
9
+ interface CloudFrontCustomOrigin {
10
+ customHeaders: CloudFrontHeaders;
11
+ domainName: string;
12
+ keepaliveTimeout: number;
13
+ path: string;
14
+ port: number;
15
+ protocol: string;
16
+ readTimeout: number;
17
+ sslProtocols: string[];
18
+ }
19
+ export interface CloudFrontRequest {
20
+ clientIp: string;
21
+ headers: CloudFrontHeaders;
22
+ method: string;
23
+ querystring: string;
24
+ uri: string;
25
+ body?: {
26
+ inputTruncated: boolean;
27
+ action: string;
28
+ encoding: string;
29
+ data: string;
30
+ };
31
+ origin?: {
32
+ custom: CloudFrontCustomOrigin;
33
+ };
34
+ }
35
+ interface CloudFrontConfig {
36
+ distributionDomainName: string;
37
+ distributionId: string;
38
+ eventType: string;
39
+ requestId: string;
40
+ }
41
+ interface CloudFrontEvent {
42
+ cf: {
43
+ config: CloudFrontConfig;
44
+ request: CloudFrontRequest;
45
+ };
46
+ }
47
+ export interface CloudFrontEdgeEvent {
48
+ Records: CloudFrontEvent[];
49
+ }
50
+ declare type CloudFrontContext = {};
51
+ export interface Callback {
52
+ (err: Error | null, result?: CloudFrontRequest | CloudFrontResult): void;
53
+ }
54
+ interface CloudFrontResult {
55
+ status: string;
56
+ statusDescription?: string;
57
+ headers?: {
58
+ [header: string]: {
59
+ key: string;
60
+ value: string;
61
+ }[];
62
+ };
63
+ body?: string;
64
+ bodyEncoding?: 'text' | 'base64';
65
+ }
66
+ /**
67
+ * Accepts events from 'Lambda@Edge' event
68
+ * https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html
69
+ */
70
+ export declare const handle: (app: Hono<any>) => (event: CloudFrontEdgeEvent, context?: CloudFrontContext, callback?: Callback) => Promise<CloudFrontResult>;
71
+ export declare const isContentTypeBinary: (contentType: string) => boolean;
72
+ export {};
@@ -0,0 +1,2 @@
1
+ export { handle } from './handler';
2
+ export type { Callback, CloudFrontRequest, CloudFrontEdgeEvent } from './handler';
@@ -0,0 +1,31 @@
1
+ import type { Context } from '../../context';
2
+ import type { MiddlewareHandler } from '../../types';
3
+ import '../../context';
4
+ declare module '../../context' {
5
+ interface ContextVariableMap {
6
+ metric?: {
7
+ headers: string[];
8
+ timers: Map<string, Timer>;
9
+ };
10
+ }
11
+ }
12
+ interface Timer {
13
+ description?: string;
14
+ start: number;
15
+ }
16
+ interface TimingOptions {
17
+ total: boolean;
18
+ enabled: boolean | ((c: Context) => boolean);
19
+ totalDescription: string;
20
+ autoEnd: boolean;
21
+ crossOrigin: boolean | string;
22
+ }
23
+ export declare const timing: (config?: Partial<TimingOptions>) => MiddlewareHandler;
24
+ interface SetMetric {
25
+ (c: Context, name: string, value: number, description?: string, precision?: number): void;
26
+ (c: Context, name: string, description?: string): void;
27
+ }
28
+ export declare const setMetric: SetMetric;
29
+ export declare const startTime: (c: Context, name: string, description?: string) => void;
30
+ export declare const endTime: (c: Context, name: string, precision?: number) => void;
31
+ export {};
@@ -3,6 +3,7 @@ export declare const splitPath: (path: string) => string[];
3
3
  export declare const splitRoutingPath: (path: string) => string[];
4
4
  export declare const getPattern: (label: string) => Pattern | null;
5
5
  export declare const getPath: (request: Request) => string;
6
+ export declare const getQueryStrings: (url: string) => string;
6
7
  export declare const getPathNoStrict: (request: Request) => string;
7
8
  export declare const mergePath: (...paths: string[]) => string;
8
9
  export declare const checkOptionalParameter: (path: string) => string[] | null;
package/dist/utils/url.js CHANGED
@@ -59,6 +59,10 @@ var getPath = (request) => {
59
59
  const queryIndex = url.indexOf("?", 8);
60
60
  return url.slice(url.indexOf("/", 8), queryIndex === -1 ? void 0 : queryIndex);
61
61
  };
62
+ var getQueryStrings = (url) => {
63
+ const queryIndex = url.indexOf("?", 8);
64
+ return queryIndex === -1 ? "" : "?" + url.slice(queryIndex + 1);
65
+ };
62
66
  var getPathNoStrict = (request) => {
63
67
  const result = getPath(request);
64
68
  return result.length > 1 && result[result.length - 1] === "/" ? result.slice(0, -1) : result;
@@ -176,6 +180,7 @@ export {
176
180
  getPattern,
177
181
  getQueryParam,
178
182
  getQueryParams,
183
+ getQueryStrings,
179
184
  mergePath,
180
185
  splitPath,
181
186
  splitRoutingPath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "3.2.7",
3
+ "version": "3.3.0",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",
@@ -14,11 +14,12 @@
14
14
  "test:deno": "env NAME=Deno deno test --allow-read --allow-env runtime_tests/deno",
15
15
  "test:bun": "env NAME=Bun bun test --jsx-import-source ../../src/middleware/jsx runtime_tests/bun/index.test.tsx",
16
16
  "test:fastly": "jest --config ./runtime_tests/fastly/jest.config.js",
17
- "test:lagon": "start-server-and-test \"lagon dev runtime_tests/lagon/index.ts\" http://127.0.0.1:1234 \"yarn jest runtime_tests/lagon/index.test.ts --testMatch '**/*.test.ts'\"",
17
+ "test:lagon": "start-server-and-test \"lagon dev runtime_tests/lagon/index.ts -e runtime_tests/lagon/.env.lagon\" http://127.0.0.1:1234 \"yarn jest runtime_tests/lagon/index.test.ts --testMatch '**/*.test.ts'\"",
18
18
  "test:node": "env NAME=Node jest --config ./runtime_tests/node/jest.config.js",
19
19
  "test:wrangler": "jest --config ./runtime_tests/wrangler/jest.config.js",
20
20
  "test:lambda": "env NAME=Node jest --config ./runtime_tests/lambda/jest.config.js",
21
- "test:all": "yarn test && yarn test:deno && yarn test:bun && yarn test:fastly && yarn test:lagon && yarn test:node && yarn test:wrangler && yarn test:lambda",
21
+ "test:lambda-edge": "env NAME=Node jest --config ./runtime_tests/lambda-edge/jest.config.js",
22
+ "test:all": "yarn test && yarn test:deno && yarn test:bun && yarn test:fastly && yarn test:lagon && yarn test:node && yarn test:wrangler && yarn test:lambda && yarn test:lambda-edge",
22
23
  "lint": "eslint --ext js,ts src .eslintrc.cjs",
23
24
  "lint:fix": "eslint --ext js,ts src .eslintrc.cjs --fix",
24
25
  "denoify": "rimraf deno_dist && denoify && rimraf 'deno_dist/**/*.test.ts'",
@@ -110,6 +111,11 @@
110
111
  "import": "./dist/middleware/jwt/index.js",
111
112
  "require": "./dist/cjs/middleware/jwt/index.js"
112
113
  },
114
+ "./timing": {
115
+ "types": "./dist/types/middleware/timing/index.d.ts",
116
+ "import": "./dist/middleware/timing/index.js",
117
+ "require": "./dist/cjs/middleware/timing/index.js"
118
+ },
113
119
  "./logger": {
114
120
  "types": "./dist/types/middleware/logger/index.d.ts",
115
121
  "import": "./dist/middleware/logger/index.js",
@@ -209,6 +215,11 @@
209
215
  "types": "./dist/types/adapter/vercel/index.d.ts",
210
216
  "import": "./dist/adapter/vercel/index.js",
211
217
  "require": "./dist/cjs/adapter/vercel/index.js"
218
+ },
219
+ "./lambda-edge": {
220
+ "types": "./dist/types/adapter/lambda-edge/index.d.ts",
221
+ "import": "./dist/adapter/lambda-edge/index.js",
222
+ "require": "./dist/cjs/adapter/lambda-edge/index.js"
212
223
  }
213
224
  },
214
225
  "typesVersions": {
@@ -258,6 +269,9 @@
258
269
  "jwt": [
259
270
  "./dist/types/middleware/jwt"
260
271
  ],
272
+ "timing": [
273
+ "./dist/types/middleware/timing"
274
+ ],
261
275
  "logger": [
262
276
  "./dist/types/middleware/logger"
263
277
  ],
@@ -317,6 +331,9 @@
317
331
  ],
318
332
  "vercel": [
319
333
  "./dist/types/adapter/vercel"
334
+ ],
335
+ "lambda-edge": [
336
+ "./dist/types/adapter/lambda-edge"
320
337
  ]
321
338
  }
322
339
  },