hono 3.7.2 → 3.7.4
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/dist/adapter/aws-lambda/handler.js +5 -2
- package/dist/adapter/aws-lambda/types.js +0 -0
- package/dist/adapter/vercel/handler.js +1 -10
- package/dist/cjs/adapter/aws-lambda/handler.js +5 -2
- package/dist/cjs/adapter/aws-lambda/types.js +16 -0
- package/dist/cjs/adapter/vercel/handler.js +1 -10
- package/dist/cjs/context.js +1 -2
- package/dist/cjs/hono-base.js +1 -1
- package/dist/cjs/jsx/index.js +1 -1
- package/dist/context.js +1 -2
- package/dist/hono-base.js +1 -1
- package/dist/jsx/index.js +1 -1
- package/dist/types/adapter/aws-lambda/handler.d.ts +2 -1
- package/dist/types/adapter/aws-lambda/index.d.ts +1 -0
- package/dist/types/adapter/aws-lambda/types.d.ts +40 -0
- package/dist/types/adapter/vercel/handler.d.ts +1 -1
- package/dist/types/context.d.ts +4 -3
- package/dist/types/hono-base.d.ts +1 -1
- package/dist/types/jsx/index.d.ts +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +2 -2
|
@@ -6,10 +6,13 @@ var getRequestContext = (event) => {
|
|
|
6
6
|
return event.requestContext;
|
|
7
7
|
};
|
|
8
8
|
var handle = (app) => {
|
|
9
|
-
return async (event) => {
|
|
9
|
+
return async (event, lambdaContext) => {
|
|
10
10
|
const req = createRequest(event);
|
|
11
11
|
const requestContext = getRequestContext(event);
|
|
12
|
-
const res = await app.fetch(req, {
|
|
12
|
+
const res = await app.fetch(req, {
|
|
13
|
+
requestContext,
|
|
14
|
+
lambdaContext
|
|
15
|
+
});
|
|
13
16
|
return createResult(res);
|
|
14
17
|
};
|
|
15
18
|
};
|
|
File without changes
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
// src/adapter/vercel/handler.ts
|
|
2
2
|
var handle = (app) => (req, requestContext) => {
|
|
3
|
-
return app.fetch(
|
|
4
|
-
req,
|
|
5
|
-
{},
|
|
6
|
-
{
|
|
7
|
-
waitUntil: requestContext?.waitUntil,
|
|
8
|
-
passThroughOnException: () => {
|
|
9
|
-
throw new Error("`passThroughOnException` is not implemented in the Vercel");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
);
|
|
3
|
+
return app.fetch(req, {}, requestContext);
|
|
13
4
|
};
|
|
14
5
|
export {
|
|
15
6
|
handle
|
|
@@ -36,10 +36,13 @@ const getRequestContext = (event) => {
|
|
|
36
36
|
return event.requestContext;
|
|
37
37
|
};
|
|
38
38
|
const handle = (app) => {
|
|
39
|
-
return async (event) => {
|
|
39
|
+
return async (event, lambdaContext) => {
|
|
40
40
|
const req = createRequest(event);
|
|
41
41
|
const requestContext = getRequestContext(event);
|
|
42
|
-
const res = await app.fetch(req, {
|
|
42
|
+
const res = await app.fetch(req, {
|
|
43
|
+
requestContext,
|
|
44
|
+
lambdaContext
|
|
45
|
+
});
|
|
43
46
|
return createResult(res);
|
|
44
47
|
};
|
|
45
48
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -22,16 +22,7 @@ __export(handler_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(handler_exports);
|
|
24
24
|
const handle = (app) => (req, requestContext) => {
|
|
25
|
-
return app.fetch(
|
|
26
|
-
req,
|
|
27
|
-
{},
|
|
28
|
-
{
|
|
29
|
-
waitUntil: requestContext?.waitUntil,
|
|
30
|
-
passThroughOnException: () => {
|
|
31
|
-
throw new Error("`passThroughOnException` is not implemented in the Vercel");
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
);
|
|
25
|
+
return app.fetch(req, {}, requestContext);
|
|
35
26
|
};
|
|
36
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
28
|
0 && (module.exports = {
|
package/dist/cjs/context.js
CHANGED
|
@@ -21,7 +21,6 @@ __export(context_exports, {
|
|
|
21
21
|
Context: () => Context
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(context_exports);
|
|
24
|
-
var import_types = require("./types");
|
|
25
24
|
var import_cookie = require("./utils/cookie");
|
|
26
25
|
var import_stream = require("./utils/stream");
|
|
27
26
|
const TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
@@ -200,7 +199,7 @@ class Context {
|
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
get event() {
|
|
203
|
-
if (this._exCtx instanceof
|
|
202
|
+
if (this._exCtx instanceof FetchEvent) {
|
|
204
203
|
return this._exCtx;
|
|
205
204
|
} else {
|
|
206
205
|
throw Error("This context has no FetchEvent");
|
package/dist/cjs/hono-base.js
CHANGED
|
@@ -209,10 +209,10 @@ class Hono extends defineDynamicClass() {
|
|
|
209
209
|
throw err;
|
|
210
210
|
}
|
|
211
211
|
dispatch(request, executionCtx, env, method) {
|
|
212
|
-
const path = this.getPath(request, { env });
|
|
213
212
|
if (method === "HEAD") {
|
|
214
213
|
return (async () => new Response(null, await this.dispatch(request, executionCtx, env, "GET")))();
|
|
215
214
|
}
|
|
215
|
+
const path = this.getPath(request, { env });
|
|
216
216
|
const { handlers, params } = this.matchRoute(method, path);
|
|
217
217
|
const c = new import_context.Context(new import_request.HonoRequest(request, path, params), {
|
|
218
218
|
env,
|
package/dist/cjs/jsx/index.js
CHANGED
|
@@ -198,7 +198,7 @@ const memo = (component, propsAreEqual = shallowEqual) => {
|
|
|
198
198
|
};
|
|
199
199
|
};
|
|
200
200
|
const Fragment = (props) => {
|
|
201
|
-
return new JSXFragmentNode("", {}, props.children
|
|
201
|
+
return new JSXFragmentNode("", {}, props.children ? [props.children] : []);
|
|
202
202
|
};
|
|
203
203
|
// Annotate the CommonJS export names for ESM import in node:
|
|
204
204
|
0 && (module.exports = {
|
package/dist/context.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/context.ts
|
|
2
|
-
import { FetchEventLike } from "./types.js";
|
|
3
2
|
import { serialize } from "./utils/cookie.js";
|
|
4
3
|
import { StreamingApi } from "./utils/stream.js";
|
|
5
4
|
var TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
@@ -178,7 +177,7 @@ var Context = class {
|
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
get event() {
|
|
181
|
-
if (this._exCtx instanceof
|
|
180
|
+
if (this._exCtx instanceof FetchEvent) {
|
|
182
181
|
return this._exCtx;
|
|
183
182
|
} else {
|
|
184
183
|
throw Error("This context has no FetchEvent");
|
package/dist/hono-base.js
CHANGED
|
@@ -187,10 +187,10 @@ var Hono = class extends defineDynamicClass() {
|
|
|
187
187
|
throw err;
|
|
188
188
|
}
|
|
189
189
|
dispatch(request, executionCtx, env, method) {
|
|
190
|
-
const path = this.getPath(request, { env });
|
|
191
190
|
if (method === "HEAD") {
|
|
192
191
|
return (async () => new Response(null, await this.dispatch(request, executionCtx, env, "GET")))();
|
|
193
192
|
}
|
|
193
|
+
const path = this.getPath(request, { env });
|
|
194
194
|
const { handlers, params } = this.matchRoute(method, path);
|
|
195
195
|
const c = new Context(new HonoRequest(request, path, params), {
|
|
196
196
|
env,
|
package/dist/jsx/index.js
CHANGED
|
@@ -173,7 +173,7 @@ var memo = (component, propsAreEqual = shallowEqual) => {
|
|
|
173
173
|
};
|
|
174
174
|
};
|
|
175
175
|
var Fragment = (props) => {
|
|
176
|
-
return new JSXFragmentNode("", {}, props.children
|
|
176
|
+
return new JSXFragmentNode("", {}, props.children ? [props.children] : []);
|
|
177
177
|
};
|
|
178
178
|
export {
|
|
179
179
|
Fragment,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Hono } from '../../hono';
|
|
2
2
|
import type { Env, Schema } from '../../types';
|
|
3
3
|
import type { ApiGatewayRequestContext, LambdaFunctionUrlRequestContext } from './custom-context';
|
|
4
|
+
import type { LambdaContext } from './types';
|
|
4
5
|
interface APIGatewayProxyEventV2 {
|
|
5
6
|
httpMethod: string;
|
|
6
7
|
headers: Record<string, string | undefined>;
|
|
@@ -36,7 +37,7 @@ interface APIGatewayProxyResult {
|
|
|
36
37
|
/**
|
|
37
38
|
* Accepts events from API Gateway/ELB(`APIGatewayProxyEvent`) and directly through Function Url(`APIGatewayProxyEventV2`)
|
|
38
39
|
*/
|
|
39
|
-
export declare const handle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => (event: APIGatewayProxyEvent | APIGatewayProxyEventV2 | LambdaFunctionUrlEvent) => Promise<APIGatewayProxyResult>;
|
|
40
|
+
export declare const handle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => (event: APIGatewayProxyEvent | APIGatewayProxyEventV2 | LambdaFunctionUrlEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>;
|
|
40
41
|
export declare const isContentTypeBinary: (contentType: string) => boolean;
|
|
41
42
|
export declare const isContentEncodingBinary: (contentEncoding: string | null) => boolean;
|
|
42
43
|
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface CognitoIdentity {
|
|
2
|
+
cognitoIdentityId: string;
|
|
3
|
+
cognitoIdentityPoolId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ClientContext {
|
|
6
|
+
client: ClientContextClient;
|
|
7
|
+
Custom?: any;
|
|
8
|
+
env: ClientContextEnv;
|
|
9
|
+
}
|
|
10
|
+
export interface ClientContextClient {
|
|
11
|
+
installationId: string;
|
|
12
|
+
appTitle: string;
|
|
13
|
+
appVersionName: string;
|
|
14
|
+
appVersionCode: string;
|
|
15
|
+
appPackageName: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ClientContextEnv {
|
|
18
|
+
platformVersion: string;
|
|
19
|
+
platform: string;
|
|
20
|
+
make: string;
|
|
21
|
+
model: string;
|
|
22
|
+
locale: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* {@link Handler} context parameter.
|
|
26
|
+
* See {@link https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html AWS documentation}.
|
|
27
|
+
*/
|
|
28
|
+
export interface LambdaContext {
|
|
29
|
+
callbackWaitsForEmptyEventLoop: boolean;
|
|
30
|
+
functionName: string;
|
|
31
|
+
functionVersion: string;
|
|
32
|
+
invokedFunctionArn: string;
|
|
33
|
+
memoryLimitInMB: string;
|
|
34
|
+
awsRequestId: string;
|
|
35
|
+
logGroupName: string;
|
|
36
|
+
logStreamName: string;
|
|
37
|
+
identity?: CognitoIdentity | undefined;
|
|
38
|
+
clientContext?: ClientContext | undefined;
|
|
39
|
+
getRemainingTimeInMillis(): number;
|
|
40
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Hono } from '../../hono';
|
|
2
|
-
export declare const handle: (app: Hono<any, any, any>) => (req: Request, requestContext:
|
|
2
|
+
export declare const handle: (app: Hono<any, any, any>) => (req: Request, requestContext: FetchEvent) => Response | Promise<Response>;
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference lib="es2022" />
|
|
2
|
+
/// <reference lib="webworker" />
|
|
1
3
|
import type { HonoRequest } from './request';
|
|
2
|
-
import { FetchEventLike } from './types';
|
|
3
4
|
import type { Env, NotFoundHandler, Input, TypedResponse } from './types';
|
|
4
5
|
import type { CookieOptions } from './utils/cookie';
|
|
5
6
|
import type { StatusCode } from './utils/http-status';
|
|
@@ -52,7 +53,7 @@ interface HTMLRespond {
|
|
|
52
53
|
}
|
|
53
54
|
declare type ContextOptions<E extends Env> = {
|
|
54
55
|
env: E['Bindings'];
|
|
55
|
-
executionCtx?:
|
|
56
|
+
executionCtx?: FetchEvent | ExecutionContext | undefined;
|
|
56
57
|
notFoundHandler?: NotFoundHandler<E>;
|
|
57
58
|
};
|
|
58
59
|
export declare class Context<E extends Env = any, P extends string = any, I extends Input = {}> {
|
|
@@ -70,7 +71,7 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
|
|
|
70
71
|
private _renderer;
|
|
71
72
|
private notFoundHandler;
|
|
72
73
|
constructor(req: HonoRequest<P, I['out']>, options?: ContextOptions<E>);
|
|
73
|
-
get event():
|
|
74
|
+
get event(): FetchEvent;
|
|
74
75
|
get executionCtx(): ExecutionContext;
|
|
75
76
|
get res(): Response;
|
|
76
77
|
set res(_res: Response | undefined);
|
|
@@ -10,11 +10,11 @@ interface RouterRoute {
|
|
|
10
10
|
}
|
|
11
11
|
declare const Hono_base: new <E_1 extends Env = Env, S_1 extends Schema = {}, BasePath_1 extends string = "/">() => {
|
|
12
12
|
all: HandlerInterface<E_1, "all", S_1, BasePath_1>;
|
|
13
|
-
options: HandlerInterface<E_1, "options", S_1, BasePath_1>;
|
|
14
13
|
get: HandlerInterface<E_1, "get", S_1, BasePath_1>;
|
|
15
14
|
post: HandlerInterface<E_1, "post", S_1, BasePath_1>;
|
|
16
15
|
put: HandlerInterface<E_1, "put", S_1, BasePath_1>;
|
|
17
16
|
delete: HandlerInterface<E_1, "delete", S_1, BasePath_1>;
|
|
17
|
+
options: HandlerInterface<E_1, "options", S_1, BasePath_1>;
|
|
18
18
|
patch: HandlerInterface<E_1, "patch", S_1, BasePath_1>;
|
|
19
19
|
} & {
|
|
20
20
|
on: OnHandlerInterface<E_1, S_1, BasePath_1>;
|
|
@@ -29,5 +29,5 @@ export declare type FC<T = Props> = (props: T & {
|
|
|
29
29
|
export declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
|
|
30
30
|
export declare const Fragment: (props: {
|
|
31
31
|
key?: string;
|
|
32
|
-
children?: Child
|
|
32
|
+
children?: Child | HtmlEscapedString;
|
|
33
33
|
}) => HtmlEscapedString;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -128,7 +128,7 @@ export declare type ValidationTargets = {
|
|
|
128
128
|
header: Record<string, string>;
|
|
129
129
|
cookie: Record<string, string>;
|
|
130
130
|
};
|
|
131
|
-
declare type ParamKeyName<NameWithPattern> = NameWithPattern extends `${infer Name}{${infer
|
|
131
|
+
declare type ParamKeyName<NameWithPattern> = NameWithPattern extends `${infer Name}{${infer Rest}` ? Rest extends `${infer _Pattern}?` ? `${Name}?` : Name : NameWithPattern;
|
|
132
132
|
declare type ParamKey<Component> = Component extends `:${infer NameWithPattern}` ? ParamKeyName<NameWithPattern> : never;
|
|
133
133
|
export declare type ParamKeys<Path> = Path extends `${infer Component}/${infer Rest}` ? ParamKey<Component> | ParamKeys<Rest> : ParamKey<Path>;
|
|
134
134
|
export declare type ParamKeyToRecord<T extends string> = T extends `${infer R}?` ? Record<R, string | undefined> : {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.4",
|
|
4
4
|
"description": "Ultrafast web framework for the Edges",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -398,7 +398,7 @@
|
|
|
398
398
|
"@types/crypto-js": "^4.1.1",
|
|
399
399
|
"@types/glob": "^8.0.0",
|
|
400
400
|
"@types/jest": "^29.4.0",
|
|
401
|
-
"@types/node": "^
|
|
401
|
+
"@types/node": "^20.8.2",
|
|
402
402
|
"@types/node-fetch": "^2.6.2",
|
|
403
403
|
"@types/supertest": "^2.0.12",
|
|
404
404
|
"@typescript-eslint/eslint-plugin": "^5.59.2",
|