hono-adapter-aws-lambda 1.3.0 → 1.3.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/dist/index.d.mts +3 -2
- package/dist/index.mjs +36 -45
- package/package.json +22 -18
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Env, Schema, Hono } from 'hono';
|
|
2
1
|
import { LambdaEvent, LambdaTriggerEvent } from '@namesmt/utils-lambda';
|
|
3
2
|
export { LambdaEvent, LambdaRequestEvent, LambdaTriggerEvent } from '@namesmt/utils-lambda';
|
|
3
|
+
import { Env, Schema, Hono } from 'hono';
|
|
4
4
|
import { Handler, APIGatewayProxyResult, APIGatewayProxyStructuredResultV2 } from 'aws-lambda';
|
|
5
5
|
export { Context as LambdaContext } from 'aws-lambda';
|
|
6
6
|
import * as hono_types from 'hono/types';
|
|
@@ -38,4 +38,5 @@ declare function createTriggerFactory<E extends Env, A extends Hono<any, any, '/
|
|
|
38
38
|
declare const triggerPathUUID: string;
|
|
39
39
|
declare function getTriggerPath(path: string): string;
|
|
40
40
|
|
|
41
|
-
export {
|
|
41
|
+
export { TriggerFactory, createTriggerFactory, getTriggerPath, handle, streamHandle, triggerPathUUID };
|
|
42
|
+
export type { LambdaHandler, LambdaHandlerResult };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { pipeline } from 'node:stream/promises';
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
import { pipeline } from 'stream/promises';
|
|
4
3
|
import { decodeBase64, encodeBase64 } from 'hono/utils/encode';
|
|
5
4
|
import { Hono } from 'hono';
|
|
6
5
|
import { mergePath } from 'hono/utils/url';
|
|
@@ -189,47 +188,41 @@ function isProxyEventV2(event) {
|
|
|
189
188
|
return Object.hasOwn(event, "rawPath");
|
|
190
189
|
}
|
|
191
190
|
|
|
192
|
-
var __defProp = Object.defineProperty;
|
|
193
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
194
|
-
var __publicField = (obj, key, value) => {
|
|
195
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
196
|
-
return value;
|
|
197
|
-
};
|
|
198
191
|
const METHOD = "TRIGGER";
|
|
199
192
|
class TriggerFactory {
|
|
193
|
+
simpleRouter = {};
|
|
194
|
+
honoApp;
|
|
195
|
+
internalApp = new Hono();
|
|
200
196
|
constructor(app) {
|
|
201
|
-
__publicField(this, "simpleRouter", {});
|
|
202
|
-
__publicField(this, "honoApp");
|
|
203
|
-
__publicField(this, "internalApp", new Hono());
|
|
204
|
-
__publicField(this, "on", (eventSource, id, ...handlers) => {
|
|
205
|
-
let thisEventSource = this.simpleRouter[eventSource];
|
|
206
|
-
if (!thisEventSource) {
|
|
207
|
-
this.simpleRouter[eventSource] = thisEventSource = {};
|
|
208
|
-
this.honoApp.on(METHOD, getTriggerPath(eventSource), async (c) => {
|
|
209
|
-
if (thisEventSource["$!"]) {
|
|
210
|
-
return this.internalApp.fetch(makeLocalRequest(METHOD, `/${eventSource}/$!`));
|
|
211
|
-
}
|
|
212
|
-
const resObj = {};
|
|
213
|
-
for (const route in thisEventSource) {
|
|
214
|
-
if (route[0] === "$")
|
|
215
|
-
continue;
|
|
216
|
-
const res = await this.internalApp.fetch(makeLocalRequest(METHOD, `/${eventSource}/${route}`));
|
|
217
|
-
resObj[route] = /^application\/json/.test(res.headers.get("content-type") || "") ? await res.json() : await res.text();
|
|
218
|
-
}
|
|
219
|
-
if (thisEventSource["$="]) {
|
|
220
|
-
return this.internalApp.fetch(makeLocalRequest(METHOD, `/${eventSource}/$=`));
|
|
221
|
-
}
|
|
222
|
-
return c.json(resObj);
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
if (thisEventSource[id])
|
|
226
|
-
throw new Error(`Route ID "${id}" already exists for event source "${eventSource}"`);
|
|
227
|
-
this.internalApp.on(METHOD, `/${eventSource}/${id}`, ...handlers);
|
|
228
|
-
thisEventSource[id] = true;
|
|
229
|
-
return this;
|
|
230
|
-
});
|
|
231
197
|
this.honoApp = app;
|
|
232
198
|
}
|
|
199
|
+
on = (eventSource, id, ...handlers) => {
|
|
200
|
+
let thisEventSource = this.simpleRouter[eventSource];
|
|
201
|
+
if (!thisEventSource) {
|
|
202
|
+
this.simpleRouter[eventSource] = thisEventSource = {};
|
|
203
|
+
this.honoApp.on(METHOD, getTriggerPath(eventSource), async (c) => {
|
|
204
|
+
if (thisEventSource["$!"]) {
|
|
205
|
+
return this.internalApp.fetch(makeLocalRequest(METHOD, `/${eventSource}/$!`));
|
|
206
|
+
}
|
|
207
|
+
const resObj = {};
|
|
208
|
+
for (const route in thisEventSource) {
|
|
209
|
+
if (route[0] === "$")
|
|
210
|
+
continue;
|
|
211
|
+
const res = await this.internalApp.fetch(makeLocalRequest(METHOD, `/${eventSource}/${route}`));
|
|
212
|
+
resObj[route] = /^application\/json/.test(res.headers.get("content-type") || "") ? await res.json() : await res.text();
|
|
213
|
+
}
|
|
214
|
+
if (thisEventSource["$="]) {
|
|
215
|
+
return this.internalApp.fetch(makeLocalRequest(METHOD, `/${eventSource}/$=`));
|
|
216
|
+
}
|
|
217
|
+
return c.json(resObj);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (thisEventSource[id])
|
|
221
|
+
throw new Error(`Route ID "${id}" already exists for event source "${eventSource}"`);
|
|
222
|
+
this.internalApp.on(METHOD, `/${eventSource}/${id}`, ...handlers);
|
|
223
|
+
thisEventSource[id] = true;
|
|
224
|
+
return this;
|
|
225
|
+
};
|
|
233
226
|
}
|
|
234
227
|
function createTriggerFactory(app) {
|
|
235
228
|
return new TriggerFactory(app);
|
|
@@ -303,18 +296,17 @@ function getProcessor(event) {
|
|
|
303
296
|
}
|
|
304
297
|
|
|
305
298
|
function minimalEvent(method, path, baseEvent) {
|
|
306
|
-
var _a;
|
|
307
299
|
const event = baseEvent ?? {};
|
|
308
|
-
event.requestContext
|
|
300
|
+
event.requestContext ??= {
|
|
309
301
|
http: {
|
|
310
302
|
method: "",
|
|
311
303
|
path: ""
|
|
312
304
|
},
|
|
313
305
|
routeKey: ""
|
|
314
|
-
}
|
|
306
|
+
};
|
|
315
307
|
if (method !== "GET" && method !== "HEAD") {
|
|
316
|
-
event.headers
|
|
317
|
-
|
|
308
|
+
event.headers ??= {};
|
|
309
|
+
event.headers["content-type"] ??= "application/json";
|
|
318
310
|
if (typeof event.body !== "string")
|
|
319
311
|
event.body = JSON.stringify(event.body);
|
|
320
312
|
}
|
|
@@ -324,7 +316,6 @@ function minimalEvent(method, path, baseEvent) {
|
|
|
324
316
|
return event;
|
|
325
317
|
}
|
|
326
318
|
|
|
327
|
-
globalThis.crypto ?? (globalThis.crypto = crypto);
|
|
328
319
|
async function writableWriteReadable(writer, reader) {
|
|
329
320
|
let readResult = await reader.read();
|
|
330
321
|
while (!readResult.done) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono-adapter-aws-lambda",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.
|
|
5
|
-
"packageManager": "pnpm@
|
|
4
|
+
"version": "1.3.2",
|
|
5
|
+
"packageManager": "pnpm@10.11.0",
|
|
6
6
|
"description": "",
|
|
7
7
|
"author": "NamesMT <dangquoctrung123@gmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"prepublishOnly": "pnpm run build"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"hono": ">=4.
|
|
56
|
+
"hono": ">=4.7.11"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"hono": {
|
|
@@ -61,27 +61,31 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@namesmt/utils-lambda": "^0.1.
|
|
65
|
-
"@types/aws-lambda": "^8.10.
|
|
64
|
+
"@namesmt/utils-lambda": "^0.1.4",
|
|
65
|
+
"@types/aws-lambda": "^8.10.149"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@antfu/eslint-config": "^
|
|
69
|
-
"@types/node": "^20.
|
|
70
|
-
"@vitest/coverage-v8": "^
|
|
71
|
-
"eslint": "^9.
|
|
68
|
+
"@antfu/eslint-config": "^4.13.2",
|
|
69
|
+
"@types/node": "^20.17.57",
|
|
70
|
+
"@vitest/coverage-v8": "^3.1.4",
|
|
71
|
+
"eslint": "^9.28.0",
|
|
72
72
|
"klona": "^2.0.6",
|
|
73
|
-
"lint-staged": "^
|
|
74
|
-
"simple-git-hooks": "^2.
|
|
75
|
-
"tsx": "^4.
|
|
76
|
-
"typescript": "^5.
|
|
77
|
-
"unbuild": "^
|
|
78
|
-
"vitest": "^
|
|
73
|
+
"lint-staged": "^16.1.0",
|
|
74
|
+
"simple-git-hooks": "^2.13.0",
|
|
75
|
+
"tsx": "^4.19.4",
|
|
76
|
+
"typescript": "^5.8.3",
|
|
77
|
+
"unbuild": "^3.5.0",
|
|
78
|
+
"vitest": "^3.1.4"
|
|
79
79
|
},
|
|
80
80
|
"pnpm": {
|
|
81
81
|
"overrides": {
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
"is-core-module": "npm:@nolyfill/is-core-module@^1.0.39"
|
|
83
|
+
},
|
|
84
|
+
"onlyBuiltDependencies": [
|
|
85
|
+
"esbuild",
|
|
86
|
+
"simple-git-hooks",
|
|
87
|
+
"unrs-resolver"
|
|
88
|
+
]
|
|
85
89
|
},
|
|
86
90
|
"simple-git-hooks": {
|
|
87
91
|
"pre-commit": "pnpm lint-staged"
|