koa 2.14.0 → 2.14.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/History.md +6 -0
- package/lib/application.js +10 -9
- package/package.json +1 -1
package/History.md
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
|
|
2
|
+
2.14.1 / 2022-12-07
|
|
3
|
+
==================
|
|
4
|
+
|
|
5
|
+
**fixes**
|
|
6
|
+
* [[`cb92bc9`](http://github.com/koajs/koa/commit/cb92bc98939bd71fd3c01e2dc681caf6545baa38)] - fix: should export createAsyncCtxStorageMiddleware function on application (#1724) (fengmk2 <<fengmk2@gmail.com>>)
|
|
7
|
+
|
|
2
8
|
2.14.0 / 2022-12-06
|
|
3
9
|
==================
|
|
4
10
|
|
package/lib/application.js
CHANGED
|
@@ -69,7 +69,7 @@ module.exports = class Application extends Emitter {
|
|
|
69
69
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
70
70
|
assert(AsyncLocalStorage, 'Requires node 12.17.0 or higher to enable asyncLocalStorage');
|
|
71
71
|
this.ctxStorage = new AsyncLocalStorage();
|
|
72
|
-
this.use(
|
|
72
|
+
this.use(this.createAsyncCtxStorageMiddleware());
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -234,15 +234,16 @@ module.exports = class Application extends Emitter {
|
|
|
234
234
|
static get default() {
|
|
235
235
|
return Application;
|
|
236
236
|
}
|
|
237
|
-
};
|
|
238
237
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
238
|
+
createAsyncCtxStorageMiddleware() {
|
|
239
|
+
const app = this;
|
|
240
|
+
return async function asyncCtxStorage(ctx, next) {
|
|
241
|
+
await app.ctxStorage.run(ctx, async() => {
|
|
242
|
+
return await next();
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
};
|
|
246
247
|
|
|
247
248
|
/**
|
|
248
249
|
* Response helper.
|