@hoajs/context-storage 0.1.0 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.1.1 / 2026-02-10
2
+
3
+ - feat: add MockContext
4
+
1
5
  ## v0.1.0 / 2025-12-11
2
6
 
3
7
  - init
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var context_storage_exports = {};
19
19
  __export(context_storage_exports, {
20
+ MockContext: () => MockContext,
20
21
  contextStorage: () => contextStorage,
21
22
  getContext: () => getContext
22
23
  });
@@ -35,8 +36,12 @@ function getContext() {
35
36
  }
36
37
  return context;
37
38
  }
39
+ function MockContext(ctx, next) {
40
+ return asyncLocalStorage.run(ctx, next);
41
+ }
38
42
  // Annotate the CommonJS export names for ESM import in node:
39
43
  0 && (module.exports = {
44
+ MockContext,
40
45
  contextStorage,
41
46
  getContext
42
47
  });
@@ -12,7 +12,11 @@ function getContext() {
12
12
  }
13
13
  return context;
14
14
  }
15
+ function MockContext(ctx, next) {
16
+ return asyncLocalStorage.run(ctx, next);
17
+ }
15
18
  export {
19
+ MockContext,
16
20
  contextStorage,
17
21
  getContext
18
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoajs/context-storage",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Context storage middleware for Hoa.",
5
5
  "main": "./dist/cjs/context-storage.js",
6
6
  "type": "module",
package/types/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import type { HoaMiddleware, HoaContext } from 'hoa'
2
2
 
3
+ type MaybePromise<T> = T | Promise<T>
4
+
3
5
  export declare function contextStorage (): HoaMiddleware
4
6
 
5
- export declare function getContext (): HoaContext
7
+ export declare function getContext (): HoaContext
8
+
9
+ export declare function MockContext<T = unknown> (ctx: HoaContext, next: () => MaybePromise<T>): MaybePromise<T>