egg 4.1.0-beta.34 → 4.1.0-beta.36
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/dist/agent.d.ts +7 -3
- package/dist/agent.js +10 -6
- package/dist/ajv.d.ts +1 -1
- package/dist/ajv.js +3 -2
- package/dist/aop.d.ts +1 -1
- package/dist/aop.js +3 -2
- package/dist/app/extend/context.d.ts +181 -178
- package/dist/app/extend/context.js +244 -259
- package/dist/app/extend/helper.d.ts +40 -35
- package/dist/app/extend/helper.js +45 -41
- package/dist/app/extend/request.d.ts +135 -131
- package/dist/app/extend/request.js +219 -258
- package/dist/app/extend/response.d.ts +28 -24
- package/dist/app/extend/response.js +36 -34
- package/dist/app/middleware/body_parser.d.ts +2 -2
- package/dist/app/middleware/body_parser.js +7 -3
- package/dist/app/middleware/meta.d.ts +8 -8
- package/dist/app/middleware/meta.js +15 -18
- package/dist/app/middleware/notfound.d.ts +8 -5
- package/dist/app/middleware/notfound.js +25 -28
- package/dist/app/middleware/override_method.d.ts +2 -2
- package/dist/app/middleware/override_method.js +7 -3
- package/dist/app/middleware/site_file.d.ts +11 -7
- package/dist/app/middleware/site_file.js +37 -52
- package/dist/config/config.default.d.ts +11 -6
- package/dist/config/config.default.js +258 -375
- package/dist/config/config.local.d.ts +6 -3
- package/dist/config/config.local.js +7 -8
- package/dist/config/config.unittest.d.ts +6 -3
- package/dist/config/config.unittest.js +10 -8
- package/dist/config/plugin.d.ts +6 -2
- package/dist/config/plugin.js +67 -131
- package/dist/dal.d.ts +1 -1
- package/dist/dal.js +3 -2
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +3 -2
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +3 -2
- package/dist/index.d.ts +24 -106
- package/dist/index.js +23 -89
- package/dist/lib/agent.d.ts +21 -15
- package/dist/lib/agent.js +53 -45
- package/dist/lib/application.d.ts +60 -54
- package/dist/lib/application.js +200 -250
- package/dist/lib/core/base_context_class.d.ts +23 -17
- package/dist/lib/core/base_context_class.js +17 -15
- package/dist/lib/core/base_context_logger.d.ts +39 -35
- package/dist/lib/core/base_context_logger.js +58 -60
- package/dist/lib/core/base_hook_class.d.ts +18 -11
- package/dist/lib/core/base_hook_class.js +26 -22
- package/dist/lib/core/context_httpclient.d.ts +21 -16
- package/dist/lib/core/context_httpclient.js +29 -26
- package/dist/lib/core/httpclient.d.ts +14 -12
- package/dist/lib/core/httpclient.js +34 -37
- package/dist/lib/core/logger.d.ts +7 -3
- package/dist/lib/core/logger.js +30 -36
- package/dist/lib/core/messenger/IMessenger.d.ts +53 -49
- package/dist/lib/core/messenger/IMessenger.js +1 -2
- package/dist/lib/core/messenger/base.d.ts +11 -7
- package/dist/lib/core/messenger/base.js +30 -29
- package/dist/lib/core/messenger/index.d.ts +10 -6
- package/dist/lib/core/messenger/index.js +11 -8
- package/dist/lib/core/messenger/ipc.d.ts +62 -57
- package/dist/lib/core/messenger/ipc.js +126 -138
- package/dist/lib/core/messenger/local.d.ts +63 -58
- package/dist/lib/core/messenger/local.js +126 -131
- package/dist/lib/core/utils.d.ts +5 -2
- package/dist/lib/core/utils.js +44 -66
- package/dist/lib/define.d.ts +72 -67
- package/dist/lib/define.js +54 -53
- package/dist/lib/egg.d.ts +283 -281
- package/dist/lib/egg.js +512 -573
- package/dist/lib/error/CookieLimitExceedError.d.ts +7 -4
- package/dist/lib/error/CookieLimitExceedError.js +15 -12
- package/dist/lib/error/MessageUnhandledRejectionError.d.ts +7 -4
- package/dist/lib/error/MessageUnhandledRejectionError.js +15 -12
- package/dist/lib/error/index.d.ts +3 -2
- package/dist/lib/error/index.js +4 -3
- package/dist/lib/loader/AgentWorkerLoader.d.ts +15 -10
- package/dist/lib/loader/AgentWorkerLoader.js +22 -18
- package/dist/lib/loader/AppWorkerLoader.d.ts +20 -15
- package/dist/lib/loader/AppWorkerLoader.js +35 -37
- package/dist/lib/loader/EggApplicationLoader.d.ts +7 -3
- package/dist/lib/loader/EggApplicationLoader.js +7 -4
- package/dist/lib/loader/index.d.ts +4 -3
- package/dist/lib/loader/index.js +5 -4
- package/dist/lib/start.d.ts +24 -20
- package/dist/lib/start.js +32 -42
- package/dist/lib/types.d.ts +288 -286
- package/dist/lib/types.js +2 -2
- package/dist/lib/types.plugin.d.ts +21 -21
- package/dist/lib/types.plugin.js +23 -24
- package/dist/orm.d.ts +1 -1
- package/dist/orm.js +3 -2
- package/dist/schedule.d.ts +2 -2
- package/dist/schedule.js +5 -5
- package/dist/transaction.d.ts +1 -1
- package/dist/transaction.js +3 -2
- package/dist/urllib.d.ts +1 -1
- package/dist/urllib.js +3 -2
- package/package.json +60 -64
package/dist/lib/agent.js
CHANGED
|
@@ -1,47 +1,55 @@
|
|
|
1
1
|
import { EggApplicationCore } from "./egg.js";
|
|
2
|
-
import { AgentWorkerLoader } from "./loader/
|
|
2
|
+
import { AgentWorkerLoader } from "./loader/AgentWorkerLoader.js";
|
|
3
|
+
import "./loader/index.js";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/agent.ts
|
|
3
6
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
7
|
+
* Singleton instance in Agent Worker, extend {@link EggApplicationCore}
|
|
8
|
+
* @augments EggApplicationCore
|
|
9
|
+
*/
|
|
10
|
+
var Agent = class extends EggApplicationCore {
|
|
11
|
+
#agentAliveHandler;
|
|
12
|
+
/**
|
|
13
|
+
* @class
|
|
14
|
+
* @param {Object} options - see {@link EggApplicationCore}
|
|
15
|
+
*/
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super({
|
|
18
|
+
...options,
|
|
19
|
+
type: "agent"
|
|
20
|
+
});
|
|
21
|
+
this.#agentAliveHandler = setInterval(() => {
|
|
22
|
+
this.coreLogger.info("[]");
|
|
23
|
+
}, 1440 * 60 * 1e3);
|
|
24
|
+
}
|
|
25
|
+
customEggLoader() {
|
|
26
|
+
return AgentWorkerLoader;
|
|
27
|
+
}
|
|
28
|
+
_wrapMessenger() {
|
|
29
|
+
for (const methodName of [
|
|
30
|
+
"broadcast",
|
|
31
|
+
"sendTo",
|
|
32
|
+
"sendToApp",
|
|
33
|
+
"sendToAgent",
|
|
34
|
+
"sendRandom"
|
|
35
|
+
]) wrapMethod(methodName, this.messenger, this.coreLogger);
|
|
36
|
+
function wrapMethod(methodName, messenger, logger) {
|
|
37
|
+
const originMethod = messenger[methodName];
|
|
38
|
+
messenger[methodName] = function(...args) {
|
|
39
|
+
const stack = (/* @__PURE__ */ new Error()).stack.split("\n").slice(1).join("\n");
|
|
40
|
+
logger.warn("agent can't call %s before server started\n%s", methodName, stack);
|
|
41
|
+
originMethod.apply(this, args);
|
|
42
|
+
};
|
|
43
|
+
messenger.prependOnceListener("egg-ready", () => {
|
|
44
|
+
messenger[methodName] = originMethod;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async close() {
|
|
49
|
+
clearInterval(this.#agentAliveHandler);
|
|
50
|
+
await super.close();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Agent };
|
|
@@ -1,56 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { IController } from "./types.js";
|
|
2
|
+
import Context from "../app/extend/context.js";
|
|
3
|
+
import { AppWorkerLoader } from "./loader/AppWorkerLoader.js";
|
|
4
|
+
import "./loader/index.js";
|
|
5
|
+
import { EggApplicationCore, EggApplicationCoreOptions } from "./egg.js";
|
|
6
|
+
import Helper from "../app/extend/helper.js";
|
|
7
|
+
import http from "node:http";
|
|
8
|
+
import { Socket } from "node:net";
|
|
9
|
+
|
|
10
|
+
//#region src/lib/application.d.ts
|
|
7
11
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
12
|
+
* Singleton instance in App Worker, extend {@link EggApplicationCore}
|
|
13
|
+
* @augments EggApplicationCore
|
|
14
|
+
*/
|
|
15
|
+
declare class Application extends EggApplicationCore {
|
|
16
|
+
#private;
|
|
17
|
+
controller: IController;
|
|
18
|
+
server?: http.Server;
|
|
19
|
+
/**
|
|
20
|
+
* reference to {@link Helper}
|
|
21
|
+
* @member {Helper} Application#Helper
|
|
22
|
+
*/
|
|
23
|
+
Helper: typeof Helper;
|
|
24
|
+
/**
|
|
25
|
+
* @class
|
|
26
|
+
* @param {Object} options - see {@link EggApplicationCore}
|
|
27
|
+
*/
|
|
28
|
+
constructor(options?: Omit<EggApplicationCoreOptions, "type">);
|
|
29
|
+
protected customEggLoader(): typeof AppWorkerLoader;
|
|
30
|
+
protected load(): Promise<void>;
|
|
31
|
+
onClientError(err: any, socket: Socket): void;
|
|
32
|
+
onServer(server: http.Server): void;
|
|
33
|
+
/**
|
|
34
|
+
* global locals for view
|
|
35
|
+
* @member {Object} Application#locals
|
|
36
|
+
* @see Context#locals
|
|
37
|
+
*/
|
|
38
|
+
get locals(): Record<string, any>;
|
|
39
|
+
set locals(val: Record<string, any>);
|
|
40
|
+
/**
|
|
41
|
+
* save routers to `run/router.json`
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
dumpConfig(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Run async function in the background
|
|
47
|
+
* @see Context#runInBackground
|
|
48
|
+
* @param {Function} scope - the first args is an anonymous ctx
|
|
49
|
+
*/
|
|
50
|
+
runInBackground(scope: (ctx: Context) => Promise<void>, req?: unknown): void;
|
|
51
|
+
/**
|
|
52
|
+
* secret key for Application
|
|
53
|
+
* @member {String} Application#keys
|
|
54
|
+
*/
|
|
55
|
+
get keys(): string[];
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated keep compatible with egg 3.x
|
|
58
|
+
*/
|
|
59
|
+
toAsyncFunction(fn: (...args: any[]) => any): (...args: any[]) => any;
|
|
56
60
|
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { Application };
|