@wyrly/hono 1.0.0 → 1.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/hono/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;GAMG;AACH,wBAAgB,EAAE,CAAC,SAAS,EAAE,SAAS,GAAG,iBAAiB,CAY1D"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/hono/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD;;;;;;GAMG;AACH,wBAAgB,EAAE,CAAC,SAAS,EAAE,SAAS,GAAG,iBAAiB,CAY1D"}
@@ -1,4 +1,5 @@
1
1
  import { HonoContextToken, RequestToken } from "./tokens.js";
2
+ import { diVariableKey } from "./types.js";
2
3
  /**
3
4
  * Creates a DI scope per request and attaches it via `c.set("di", scope)`.
4
5
  * Disposes the scope after `await next()` (including on handler error, via `finally`).
@@ -11,7 +12,7 @@ export function di(container) {
11
12
  const scope = container.createScope();
12
13
  scope.set(HonoContextToken, c);
13
14
  scope.set(RequestToken, c.req.raw);
14
- c.set("di", scope);
15
+ c.set(diVariableKey, scope);
15
16
  try {
16
17
  await next();
17
18
  }
package/esm/hono/mod.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import "./types.js";
2
1
  export { di } from "./middleware.js";
3
2
  export { HonoContextToken, RequestToken } from "./tokens.js";
3
+ export { diVariableKey, getDI, type HonoDIVariables } from "./types.js";
4
4
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/hono/mod.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AAEpB,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/hono/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC"}
package/esm/hono/mod.js CHANGED
@@ -1,3 +1,3 @@
1
- import "./types.js";
2
1
  export { di } from "./middleware.js";
3
2
  export { HonoContextToken, RequestToken } from "./tokens.js";
3
+ export { diVariableKey, getDI } from "./types.js";
@@ -1,8 +1,11 @@
1
+ import type { Context } from "hono";
1
2
  import type { Scope } from "../core/mod.js";
2
- declare module "hono" {
3
- interface ContextVariableMap {
4
- /** DI scope for this HTTP request */
5
- di: Scope;
6
- }
7
- }
3
+ /** Context variable key used by `di()` middleware. */
4
+ export declare const diVariableKey: "di";
5
+ /** Pass to `new Hono<{ Variables: HonoDIVariables }>()` for typed `getDI(c)`. */
6
+ export type HonoDIVariables = {
7
+ [diVariableKey]: Scope;
8
+ };
9
+ /** Read the request DI scope set by `di()` (use when `Variables` is not generic). */
10
+ export declare function getDI(c: Context): Scope;
8
11
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hono/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,kBAAkB;QAC1B,qCAAqC;QACrC,EAAE,EAAE,KAAK,CAAC;KACX;CACF"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hono/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,sDAAsD;AACtD,eAAO,MAAM,aAAa,EAAG,IAAa,CAAC;AAE3C,iFAAiF;AACjF,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC;CACxB,CAAC;AAEF,qFAAqF;AACrF,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAEvC"}
package/esm/hono/types.js CHANGED
@@ -1 +1,6 @@
1
- export {};
1
+ /** Context variable key used by `di()` middleware. */
2
+ export const diVariableKey = "di";
3
+ /** Read the request DI scope set by `di()` (use when `Variables` is not generic). */
4
+ export function getDI(c) {
5
+ return c.get(diVariableKey);
6
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@wyrly/hono",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "Wyrly DI adapter for Hono",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/wyrly/wyrly.git",
8
- "directory": "oss/packages/hono"
7
+ "url": "git+https://github.com/valid-lab/wyrly.git",
8
+ "directory": "packages/hono"
9
9
  },
10
10
  "license": "Apache-2.0",
11
11
  "module": "./esm/hono/mod.js",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "hono": "4",
21
21
  "@deno/shim-deno": "~0.18.0",
22
- "@wyrly/core": "^1.0.0"
22
+ "@wyrly/core": "^1.0.3"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "hono": "^4.0.0"