@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 +4 -0
- package/dist/cjs/context-storage.js +5 -0
- package/dist/esm/context-storage.js +4 -0
- package/package.json +1 -1
- package/types/index.d.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -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
|
});
|
package/package.json
CHANGED
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>
|