egg 3.14.2 → 3.16.0

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/index.d.ts CHANGED
@@ -729,8 +729,9 @@ declare module 'egg' {
729
729
  * Run async function in the anonymous context scope
730
730
  * @see Context#runInAnonymousContextScope
731
731
  * @param {Function} scope - the first args is an anonymous ctx, scope should be async function
732
+ * @param {Request} req - if you want to mock request like querystring, you can pass an object to this function.
732
733
  */
733
- runInAnonymousContextScope(scope: (ctx: Context) => Promise<void>): Promise<void>;
734
+ runInAnonymousContextScope<R>(scope: (ctx: Context) => Promise<R>, req?: Request): Promise<R>;
734
735
 
735
736
  /**
736
737
  * Get current execute ctx async local storage
@@ -260,12 +260,13 @@ class Application extends EggApplication {
260
260
  * Run async function in the anonymous context scope
261
261
  * @see Context#runInAnonymousContextScope
262
262
  * @param {Function} scope - the first args is an anonymous ctx, scope should be async function
263
+ * @param {Request} [req] - if you want to mock request like querystring, you can pass an object to this function.
263
264
  */
264
- async runInAnonymousContextScope(scope) {
265
- const ctx = this.createAnonymousContext();
265
+ async runInAnonymousContextScope(scope, req) {
266
+ const ctx = this.createAnonymousContext(req);
266
267
  if (!scope.name) scope._name = eggUtils.getCalleeFromStack(true);
267
- await this.ctxStorage.run(ctx, async () => {
268
- await scope(ctx);
268
+ return await this.ctxStorage.run(ctx, async () => {
269
+ return await scope(ctx);
269
270
  });
270
271
  }
271
272
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const debug = require('debug')('egg:util:messenger:ipc');
3
+ const debug = require('util').debuglog('egg:util:messenger:ipc');
4
4
  const is = require('is-type-of');
5
5
  const sendmessage = require('sendmessage');
6
6
  const EventEmitter = require('events');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const debug = require('debug')('egg:util:messenger:local');
3
+ const debug = require('util').debuglog('egg:util:messenger:local');
4
4
  const is = require('is-type-of');
5
5
  const EventEmitter = require('events');
6
6
 
package/lib/egg.js CHANGED
@@ -510,7 +510,7 @@ class EggApplication extends EggCore {
510
510
  * Create an anonymous context, the context isn't request level, so the request is mocked.
511
511
  * then you can use context level API like `ctx.service`
512
512
  * @member {String} EggApplication#createAnonymousContext
513
- * @param {Request} req - if you want to mock request like querystring, you can pass an object to this function.
513
+ * @param {Request} [req] - if you want to mock request like querystring, you can pass an object to this function.
514
514
  * @return {Context} context
515
515
  */
516
516
  createAnonymousContext(req) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "3.14.2",
3
+ "version": "3.16.0",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },
@@ -24,7 +24,6 @@
24
24
  "cache-content-type": "^1.0.1",
25
25
  "circular-json-for-egg": "^1.0.0",
26
26
  "cluster-client": "^3.3.0",
27
- "debug": "^4.3.4",
28
27
  "delegates": "^1.0.0",
29
28
  "egg-cluster": "^2.0.0",
30
29
  "egg-cookies": "^2.6.1",
@@ -38,7 +37,7 @@
38
37
  "egg-multipart": "^3.1.0",
39
38
  "egg-onerror": "^2.1.1",
40
39
  "egg-schedule": "^4.0.0",
41
- "egg-security": "^2.11.0",
40
+ "egg-security": "^3.0.0",
42
41
  "egg-session": "^3.3.0",
43
42
  "egg-static": "^2.2.0",
44
43
  "egg-view": "^2.1.3",
@@ -60,7 +59,7 @@
60
59
  },
61
60
  "devDependencies": {
62
61
  "@eggjs/tsconfig": "^1.1.0",
63
- "@types/node": "^18.11.18",
62
+ "@types/node": "^20.1.2",
64
63
  "@umijs/preset-react": "^2.1.6",
65
64
  "address": "^1.2.1",
66
65
  "antd": "^4.23.2",
@@ -68,8 +67,8 @@
68
67
  "coffee": "^5.4.0",
69
68
  "dumi": "^1.1.47",
70
69
  "dumi-theme-egg": "^1.2.2",
71
- "egg-bin": "^5",
72
- "egg-mock": "^5.9.2",
70
+ "egg-bin": "^6",
71
+ "egg-mock": "^5",
73
72
  "egg-plugin-puml": "^2.4.0",
74
73
  "egg-tracer": "^2.0.0",
75
74
  "egg-view-nunjucks": "^2.3.0",
@@ -91,8 +90,8 @@
91
90
  "spy": "^1.0.0",
92
91
  "supertest": "^6.2.4",
93
92
  "ts-node": "^10.9.1",
94
- "tsd": "^0.25.0",
95
- "typescript": "^4.8.3",
93
+ "tsd": "^0.28.1",
94
+ "typescript": "^5.0.4",
96
95
  "umi": "^3.5.36"
97
96
  },
98
97
  "main": "index.js",
@@ -109,9 +108,9 @@
109
108
  "lint": "eslint app config lib test *.js",
110
109
  "tsd": "tsd",
111
110
  "test": "npm run lint -- --fix && npm run tsd && npm run test-local",
112
- "test-local": "egg-bin test",
113
- "test-local-changed": "egg-bin test --changed",
114
- "cov": "egg-bin cov --timeout 100000",
111
+ "test-local": "egg-bin test --ts false",
112
+ "test-local-changed": "egg-bin test --changed --ts false",
113
+ "cov": "egg-bin cov --timeout 100000 --ts false",
115
114
  "ci": "npm run lint && npm run tsd && npm run cov",
116
115
  "site:dev": "APP_ROOT=./site dumi dev",
117
116
  "site:build": "APP_ROOT=./site dumi build",