@wyrly/express 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/express/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,cAAc,EAAY,MAAM,SAAS,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,CAejE"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/express/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,cAAc,EAAY,MAAM,SAAS,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,CAejE"}
@@ -1,4 +1,5 @@
1
1
  import { ExpressRequestToken, ExpressResponseToken } from "./tokens.js";
2
+ import { asExpressRequestWithDI } from "./types.js";
2
3
  /**
3
4
  * Creates a DI scope per request and attaches it to `req.di`.
4
5
  * Disposes the scope on response `finish` / `close`.
@@ -11,7 +12,7 @@ export function diMiddleware(container) {
11
12
  const scope = container.createScope();
12
13
  scope.set(ExpressRequestToken, req);
13
14
  scope.set(ExpressResponseToken, res);
14
- req.di = scope;
15
+ asExpressRequestWithDI(req).di = scope;
15
16
  const disposeScope = () => {
16
17
  void scope.dispose();
17
18
  };
@@ -1,4 +1,4 @@
1
- import "./types.js";
2
1
  export { diMiddleware } from "./middleware.js";
3
2
  export { ExpressRequestToken, ExpressResponseToken } from "./tokens.js";
3
+ export { asExpressRequestWithDI, type ExpressRequestWithDI } from "./types.js";
4
4
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/express/mod.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/express/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,3 +1,3 @@
1
- import "./types.js";
2
1
  export { diMiddleware } from "./middleware.js";
3
2
  export { ExpressRequestToken, ExpressResponseToken } from "./tokens.js";
3
+ export { asExpressRequestWithDI } from "./types.js";
@@ -1,10 +1,9 @@
1
+ import type { Request } from "express";
1
2
  import type { Scope } from "../core/mod.js";
2
- declare global {
3
- namespace Express {
4
- interface Request {
5
- /** DI scope for this HTTP request */
6
- di: Scope;
7
- }
8
- }
9
- }
3
+ /** Express `Request` with the DI scope attached by `diMiddleware`. */
4
+ export type ExpressRequestWithDI = Request & {
5
+ di: Scope;
6
+ };
7
+ /** Narrow `req` after `diMiddleware` (use instead of casting when route generics block overlap). */
8
+ export declare function asExpressRequestWithDI(req: Request): ExpressRequestWithDI;
10
9
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/express/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,qCAAqC;YACrC,EAAE,EAAE,KAAK,CAAC;SACX;KACF;CACF"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/express/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,sEAAsE;AACtE,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC;AAE3D,oGAAoG;AACpG,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CAEzE"}
@@ -1 +1,4 @@
1
- export {};
1
+ /** Narrow `req` after `diMiddleware` (use instead of casting when route generics block overlap). */
2
+ export function asExpressRequestWithDI(req) {
3
+ return req;
4
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@wyrly/express",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "Wyrly DI adapter for Express",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/wyrly/wyrly.git",
8
- "directory": "oss/packages/express"
7
+ "url": "git+https://github.com/valid-lab/wyrly.git",
8
+ "directory": "packages/express"
9
9
  },
10
10
  "license": "Apache-2.0",
11
11
  "module": "./esm/express/mod.js",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "express": "5",
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
  "express": "^5.0.0"