hono-adapter-aws-lambda 1.3.0 → 1.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/dist/index.d.mts CHANGED
@@ -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 { type LambdaHandler, type LambdaHandlerResult, TriggerFactory, createTriggerFactory, getTriggerPath, handle, streamHandle, triggerPathUUID };
41
+ export { TriggerFactory, createTriggerFactory, getTriggerPath, handle, streamHandle, triggerPathUUID };
42
+ export type { LambdaHandler, LambdaHandlerResult };
package/dist/index.mjs CHANGED
@@ -189,47 +189,41 @@ function isProxyEventV2(event) {
189
189
  return Object.hasOwn(event, "rawPath");
190
190
  }
191
191
 
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
192
  const METHOD = "TRIGGER";
199
193
  class TriggerFactory {
194
+ simpleRouter = {};
195
+ honoApp;
196
+ internalApp = new Hono();
200
197
  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
198
  this.honoApp = app;
232
199
  }
200
+ on = (eventSource, id, ...handlers) => {
201
+ let thisEventSource = this.simpleRouter[eventSource];
202
+ if (!thisEventSource) {
203
+ this.simpleRouter[eventSource] = thisEventSource = {};
204
+ this.honoApp.on(METHOD, getTriggerPath(eventSource), async (c) => {
205
+ if (thisEventSource["$!"]) {
206
+ return this.internalApp.fetch(makeLocalRequest(METHOD, `/${eventSource}/$!`));
207
+ }
208
+ const resObj = {};
209
+ for (const route in thisEventSource) {
210
+ if (route[0] === "$")
211
+ continue;
212
+ const res = await this.internalApp.fetch(makeLocalRequest(METHOD, `/${eventSource}/${route}`));
213
+ resObj[route] = /^application\/json/.test(res.headers.get("content-type") || "") ? await res.json() : await res.text();
214
+ }
215
+ if (thisEventSource["$="]) {
216
+ return this.internalApp.fetch(makeLocalRequest(METHOD, `/${eventSource}/$=`));
217
+ }
218
+ return c.json(resObj);
219
+ });
220
+ }
221
+ if (thisEventSource[id])
222
+ throw new Error(`Route ID "${id}" already exists for event source "${eventSource}"`);
223
+ this.internalApp.on(METHOD, `/${eventSource}/${id}`, ...handlers);
224
+ thisEventSource[id] = true;
225
+ return this;
226
+ };
233
227
  }
234
228
  function createTriggerFactory(app) {
235
229
  return new TriggerFactory(app);
@@ -303,18 +297,17 @@ function getProcessor(event) {
303
297
  }
304
298
 
305
299
  function minimalEvent(method, path, baseEvent) {
306
- var _a;
307
300
  const event = baseEvent ?? {};
308
- event.requestContext ?? (event.requestContext = {
301
+ event.requestContext ??= {
309
302
  http: {
310
303
  method: "",
311
304
  path: ""
312
305
  },
313
306
  routeKey: ""
314
- });
307
+ };
315
308
  if (method !== "GET" && method !== "HEAD") {
316
- event.headers ?? (event.headers = {});
317
- (_a = event.headers)["content-type"] ?? (_a["content-type"] = "application/json");
309
+ event.headers ??= {};
310
+ event.headers["content-type"] ??= "application/json";
318
311
  if (typeof event.body !== "string")
319
312
  event.body = JSON.stringify(event.body);
320
313
  }
@@ -324,7 +317,7 @@ function minimalEvent(method, path, baseEvent) {
324
317
  return event;
325
318
  }
326
319
 
327
- globalThis.crypto ?? (globalThis.crypto = crypto);
320
+ globalThis.crypto ??= crypto;
328
321
  async function writableWriteReadable(writer, reader) {
329
322
  let readResult = await reader.read();
330
323
  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.0",
5
- "packageManager": "pnpm@9.8.0",
4
+ "version": "1.3.1",
5
+ "packageManager": "pnpm@10.8.1",
6
6
  "description": "",
7
7
  "author": "NamesMT <dangquoctrung123@gmail.com>",
8
8
  "license": "MIT",
@@ -61,26 +61,25 @@
61
61
  }
62
62
  },
63
63
  "dependencies": {
64
- "@namesmt/utils-lambda": "^0.1.1",
65
- "@types/aws-lambda": "^8.10.143"
64
+ "@namesmt/utils-lambda": "^0.1.3",
65
+ "@types/aws-lambda": "^8.10.149"
66
66
  },
67
67
  "devDependencies": {
68
- "@antfu/eslint-config": "^2.27.1",
69
- "@types/node": "^20.16.1",
70
- "@vitest/coverage-v8": "^2.0.5",
71
- "eslint": "^9.9.1",
68
+ "@antfu/eslint-config": "^2.27.3",
69
+ "@types/node": "^20.17.30",
70
+ "@vitest/coverage-v8": "^2.1.9",
71
+ "eslint": "^9.24.0",
72
72
  "klona": "^2.0.6",
73
- "lint-staged": "^15.2.9",
74
- "simple-git-hooks": "^2.11.1",
75
- "tsx": "^4.17.0",
76
- "typescript": "^5.5.4",
77
- "unbuild": "^2.0.0",
78
- "vitest": "^2.0.5"
73
+ "lint-staged": "^15.5.1",
74
+ "simple-git-hooks": "^2.12.1",
75
+ "tsx": "^4.19.3",
76
+ "typescript": "^5.8.3",
77
+ "unbuild": "^3.5.0",
78
+ "vitest": "^2.1.9"
79
79
  },
80
80
  "pnpm": {
81
81
  "overrides": {
82
- "hasown": "npm:@nolyfill/hasown@^1",
83
- "is-core-module": "npm:@nolyfill/is-core-module@^1"
82
+ "is-core-module": "npm:@nolyfill/is-core-module@^1.0.39"
84
83
  }
85
84
  },
86
85
  "simple-git-hooks": {