@eggjs/core 6.4.1 → 6.6.0-beta.2

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.
Files changed (87) hide show
  1. package/README.md +23 -27
  2. package/dist/base_context_class.d.ts +21 -0
  3. package/dist/base_context_class.js +40 -0
  4. package/dist/egg.d.ts +248 -0
  5. package/dist/egg.js +358 -0
  6. package/dist/index.d.ts +12 -0
  7. package/dist/index.js +12 -0
  8. package/dist/lifecycle.d.ts +84 -0
  9. package/dist/lifecycle.js +280 -0
  10. package/dist/loader/context_loader.d.ts +39 -0
  11. package/dist/loader/context_loader.js +79 -0
  12. package/dist/loader/egg_loader.d.ts +374 -0
  13. package/dist/loader/egg_loader.js +1184 -0
  14. package/dist/loader/file_loader.d.ts +105 -0
  15. package/dist/loader/file_loader.js +198 -0
  16. package/dist/singleton.d.ts +33 -0
  17. package/dist/singleton.js +107 -0
  18. package/{src/types.ts → dist/types.d.ts} +7 -7
  19. package/dist/utils/index.d.ts +19 -0
  20. package/dist/utils/index.js +103 -0
  21. package/dist/utils/sequencify.d.ts +16 -0
  22. package/dist/utils/sequencify.js +46 -0
  23. package/dist/utils/timing.d.ts +24 -0
  24. package/dist/utils/timing.js +85 -0
  25. package/package.json +35 -63
  26. package/dist/commonjs/base_context_class.d.ts +0 -16
  27. package/dist/commonjs/base_context_class.js +0 -41
  28. package/dist/commonjs/egg.d.ts +0 -247
  29. package/dist/commonjs/egg.js +0 -401
  30. package/dist/commonjs/index.d.ts +0 -12
  31. package/dist/commonjs/index.js +0 -32
  32. package/dist/commonjs/lifecycle.d.ts +0 -78
  33. package/dist/commonjs/lifecycle.js +0 -312
  34. package/dist/commonjs/loader/context_loader.d.ts +0 -35
  35. package/dist/commonjs/loader/context_loader.js +0 -110
  36. package/dist/commonjs/loader/egg_loader.d.ts +0 -369
  37. package/dist/commonjs/loader/egg_loader.js +0 -1543
  38. package/dist/commonjs/loader/file_loader.d.ts +0 -100
  39. package/dist/commonjs/loader/file_loader.js +0 -262
  40. package/dist/commonjs/package.json +0 -3
  41. package/dist/commonjs/singleton.d.ts +0 -29
  42. package/dist/commonjs/singleton.js +0 -125
  43. package/dist/commonjs/types.d.ts +0 -53
  44. package/dist/commonjs/types.js +0 -3
  45. package/dist/commonjs/utils/index.d.ts +0 -17
  46. package/dist/commonjs/utils/index.js +0 -117
  47. package/dist/commonjs/utils/sequencify.d.ts +0 -13
  48. package/dist/commonjs/utils/sequencify.js +0 -59
  49. package/dist/commonjs/utils/timing.d.ts +0 -21
  50. package/dist/commonjs/utils/timing.js +0 -100
  51. package/dist/esm/base_context_class.d.ts +0 -16
  52. package/dist/esm/base_context_class.js +0 -37
  53. package/dist/esm/egg.d.ts +0 -247
  54. package/dist/esm/egg.js +0 -388
  55. package/dist/esm/index.d.ts +0 -12
  56. package/dist/esm/index.js +0 -12
  57. package/dist/esm/lifecycle.d.ts +0 -78
  58. package/dist/esm/lifecycle.js +0 -305
  59. package/dist/esm/loader/context_loader.d.ts +0 -35
  60. package/dist/esm/loader/context_loader.js +0 -102
  61. package/dist/esm/loader/egg_loader.d.ts +0 -369
  62. package/dist/esm/loader/egg_loader.js +0 -1536
  63. package/dist/esm/loader/file_loader.d.ts +0 -100
  64. package/dist/esm/loader/file_loader.js +0 -255
  65. package/dist/esm/package.json +0 -3
  66. package/dist/esm/singleton.d.ts +0 -29
  67. package/dist/esm/singleton.js +0 -118
  68. package/dist/esm/types.d.ts +0 -53
  69. package/dist/esm/types.js +0 -2
  70. package/dist/esm/utils/index.d.ts +0 -17
  71. package/dist/esm/utils/index.js +0 -112
  72. package/dist/esm/utils/sequencify.d.ts +0 -13
  73. package/dist/esm/utils/sequencify.js +0 -56
  74. package/dist/esm/utils/timing.d.ts +0 -21
  75. package/dist/esm/utils/timing.js +0 -93
  76. package/dist/package.json +0 -4
  77. package/src/base_context_class.ts +0 -39
  78. package/src/egg.ts +0 -517
  79. package/src/index.ts +0 -14
  80. package/src/lifecycle.ts +0 -399
  81. package/src/loader/context_loader.ts +0 -121
  82. package/src/loader/egg_loader.ts +0 -1722
  83. package/src/loader/file_loader.ts +0 -308
  84. package/src/singleton.ts +0 -149
  85. package/src/utils/index.ts +0 -125
  86. package/src/utils/sequencify.ts +0 -70
  87. package/src/utils/timing.ts +0 -114
@@ -0,0 +1,24 @@
1
+ //#region src/utils/timing.d.ts
2
+ interface TimingItem {
3
+ name: string;
4
+ start: number;
5
+ end?: number;
6
+ duration?: number;
7
+ pid: number;
8
+ index: number;
9
+ }
10
+ declare class Timing {
11
+ #private;
12
+ constructor();
13
+ init(): void;
14
+ start(name?: string, start?: number): TimingItem | undefined;
15
+ end(name?: string): TimingItem | undefined;
16
+ enable(): void;
17
+ disable(): void;
18
+ clear(): void;
19
+ toJSON(): TimingItem[];
20
+ itemToString(timelineEnd: number, item: TimingItem, times: number): string;
21
+ toString(prefix?: string, width?: number): string;
22
+ }
23
+ //#endregion
24
+ export { Timing, TimingItem };
@@ -0,0 +1,85 @@
1
+ import { debuglog } from "node:util";
2
+ import assert from "node:assert";
3
+ import { EOL } from "node:os";
4
+
5
+ //#region src/utils/timing.ts
6
+ const debug = debuglog("egg/core/utils/timing");
7
+ var Timing = class {
8
+ #enable;
9
+ #startTime;
10
+ #map;
11
+ #list;
12
+ constructor() {
13
+ this.#enable = true;
14
+ this.#map = /* @__PURE__ */ new Map();
15
+ this.#list = [];
16
+ this.init();
17
+ }
18
+ init() {
19
+ this.start("Process Start", Date.now() - Math.floor(process.uptime() * 1e3));
20
+ this.end("Process Start");
21
+ if ("scriptStartTime" in process && typeof process.scriptStartTime === "number") {
22
+ this.start("Script Start", process.scriptStartTime);
23
+ this.end("Script Start");
24
+ }
25
+ }
26
+ start(name, start) {
27
+ if (!name || !this.#enable) return;
28
+ if (this.#map.has(name)) this.end(name);
29
+ start = start || Date.now();
30
+ if (!this.#startTime) this.#startTime = start;
31
+ const item = {
32
+ name,
33
+ start,
34
+ pid: process.pid,
35
+ index: this.#list.length
36
+ };
37
+ this.#map.set(name, item);
38
+ this.#list.push(item);
39
+ debug("start %j", item);
40
+ return item;
41
+ }
42
+ end(name) {
43
+ if (!name || !this.#enable) return;
44
+ const item = this.#map.get(name);
45
+ assert(item, `should run timing.start('${name}') first`);
46
+ item.end = Date.now();
47
+ item.duration = item.end - item.start;
48
+ debug("end %j", item);
49
+ return item;
50
+ }
51
+ enable() {
52
+ this.#enable = true;
53
+ }
54
+ disable() {
55
+ this.#enable = false;
56
+ }
57
+ clear() {
58
+ this.#map.clear();
59
+ this.#list = [];
60
+ }
61
+ toJSON() {
62
+ return this.#list;
63
+ }
64
+ itemToString(timelineEnd, item, times) {
65
+ const isEnd = typeof item.duration === "number";
66
+ const duration = isEnd ? item.duration : timelineEnd - item.start;
67
+ const offset = item.start - this.#startTime;
68
+ const status = `${duration}ms${isEnd ? "" : " NOT_END"}`;
69
+ const timespan = Math.floor(Number((offset * times).toFixed(6)));
70
+ let timeline = Math.floor(Number((duration * times).toFixed(6)));
71
+ timeline = timeline > 0 ? timeline : 1;
72
+ const message = `#${item.index} ${item.name}`;
73
+ return " ".repeat(timespan) + "▇".repeat(timeline) + ` [${status}] - ${message}`;
74
+ }
75
+ toString(prefix = "egg start timeline:", width = 50) {
76
+ const timelineEnd = Date.now();
77
+ const timelineDuration = timelineEnd - this.#startTime;
78
+ let times = 1;
79
+ if (timelineDuration > width) times = width / timelineDuration;
80
+ return prefix + EOL + this.#list.map((item) => this.itemToString(timelineEnd, item, times)).join(EOL);
81
+ }
82
+ };
83
+
84
+ //#endregion
85
+ export { Timing };
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
1
  {
2
2
  "name": "@eggjs/core",
3
- "version": "6.4.1",
3
+ "version": "6.6.0-beta.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "type": "module",
11
+ "exports": {
12
+ ".": "./dist/index.js",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "main": "./dist/index.js",
16
+ "module": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
7
18
  "engines": {
8
- "node": ">= 18.19.0"
19
+ "node": ">= 20.19.0"
9
20
  },
10
21
  "description": "A core plugin framework based on @eggjs/koa",
11
- "scripts": {
12
- "clean": "rimraf dist",
13
- "lint": "eslint src test --ext ts",
14
- "pretest": "npm run clean && npm run lint -- --fix && npm run prepublishOnly",
15
- "test": "egg-bin test",
16
- "posttest": "npm run clean",
17
- "test-local": "egg-bin test",
18
- "preci": "npm run clean && npm run lint && npm run prepublishOnly",
19
- "ci": "egg-bin cov",
20
- "postci": "npm run clean",
21
- "prepublishOnly": "tshy && tshy-after && attw --pack"
22
- },
23
22
  "repository": {
24
23
  "type": "git",
25
- "url": "git+https://github.com/eggjs/core.git"
24
+ "url": "git://github.com/eggjs/egg.git",
25
+ "directory": "packages/core"
26
26
  },
27
27
  "keywords": [
28
28
  "egg",
@@ -33,71 +33,43 @@
33
33
  "bugs": {
34
34
  "url": "https://github.com/eggjs/egg/issues"
35
35
  },
36
- "homepage": "https://github.com/eggjs/core#readme",
37
36
  "dependencies": {
38
- "@eggjs/koa": "^2.20.6",
39
37
  "@eggjs/router": "^3.0.5",
40
- "@eggjs/utils": "^4.3.0",
41
38
  "egg-logger": "^3.5.0",
42
39
  "egg-path-matching": "^2.0.0",
43
- "extend2": "^4.0.0",
44
40
  "get-ready": "^3.1.0",
45
41
  "globby": "^11.0.2",
46
- "is-type-of": "^2.1.0",
42
+ "is-type-of": "^2.2.0",
47
43
  "node-homedir": "^2.0.0",
48
44
  "performance-ms": "^1.1.0",
49
45
  "ready-callback": "^4.0.0",
50
46
  "tsconfig-paths": "^4.2.0",
51
- "utility": "^2.1.0"
47
+ "utility": "^2.5.0",
48
+ "@eggjs/koa": "3.1.0-beta.2",
49
+ "@eggjs/utils": "4.5.0-beta.2",
50
+ "@eggjs/extend2": "4.1.0-beta.2"
52
51
  },
53
52
  "devDependencies": {
54
- "@arethetypeswrong/cli": "^0.17.1",
55
- "@eggjs/bin": "7",
56
- "@eggjs/supertest": "^8.1.1",
57
- "@eggjs/tsconfig": "1",
58
53
  "@types/js-yaml": "4",
59
- "@types/mocha": "10",
60
- "@types/node": "22",
54
+ "@types/node": "24",
61
55
  "await-event": "2",
62
56
  "coffee": "5",
63
- "eslint": "8",
64
- "eslint-config-egg": "14",
57
+ "husky": "9",
58
+ "prettier": "^3.4.2",
65
59
  "gals": "1",
66
60
  "js-yaml": "3",
67
61
  "mm": "^4.0.2",
68
- "pedding": "2",
69
- "rimraf": "6",
70
- "ts-node": "10",
71
- "tshy": "3",
72
- "tshy-after": "1",
62
+ "pedding": "^2.0.1",
63
+ "tsdown": "^0.14.2",
73
64
  "typescript": "5",
74
- "urllib": "4"
65
+ "urllib": "^4.6.11",
66
+ "@eggjs/mock": "6.1.0-beta.2",
67
+ "@eggjs/supertest": "8.3.0-beta.2",
68
+ "@eggjs/tsconfig": "3.1.0-beta.2"
75
69
  },
76
- "files": [
77
- "dist",
78
- "src"
79
- ],
80
- "type": "module",
81
- "tshy": {
82
- "exports": {
83
- "./package.json": "./package.json",
84
- ".": "./src/index.ts"
85
- }
86
- },
87
- "exports": {
88
- "./package.json": "./package.json",
89
- ".": {
90
- "import": {
91
- "types": "./dist/esm/index.d.ts",
92
- "default": "./dist/esm/index.js"
93
- },
94
- "require": {
95
- "types": "./dist/commonjs/index.d.ts",
96
- "default": "./dist/commonjs/index.js"
97
- }
98
- }
99
- },
100
- "main": "./dist/commonjs/index.js",
101
- "types": "./dist/commonjs/index.d.ts",
102
- "module": "./dist/esm/index.js"
103
- }
70
+ "scripts": {
71
+ "build": "tsdown",
72
+ "lint": "oxlint",
73
+ "test": "vitest run"
74
+ }
75
+ }
@@ -1,16 +0,0 @@
1
- import type { EggCore, Context } from './egg.js';
2
- /**
3
- * BaseContextClass is a base class that can be extended,
4
- * it's instantiated in context level,
5
- * {@link Helper}, {@link Service} is extending it.
6
- */
7
- export declare class BaseContextClass {
8
- ctx: Context;
9
- app: EggCore;
10
- config: Record<string, any>;
11
- service: BaseContextClass;
12
- /**
13
- * @since 1.0.0
14
- */
15
- constructor(ctx: Context);
16
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseContextClass = void 0;
4
- /**
5
- * BaseContextClass is a base class that can be extended,
6
- * it's instantiated in context level,
7
- * {@link Helper}, {@link Service} is extending it.
8
- */
9
- class BaseContextClass {
10
- ctx;
11
- app;
12
- config;
13
- service;
14
- /**
15
- * @since 1.0.0
16
- */
17
- constructor(ctx) {
18
- /**
19
- * @member {Context} BaseContextClass#ctx
20
- * @since 1.0.0
21
- */
22
- this.ctx = ctx;
23
- /**
24
- * @member {Application} BaseContextClass#app
25
- * @since 1.0.0
26
- */
27
- this.app = ctx.app;
28
- /**
29
- * @member {Config} BaseContextClass#config
30
- * @since 1.0.0
31
- */
32
- this.config = ctx.app.config;
33
- /**
34
- * @member {Service} BaseContextClass#service
35
- * @since 1.0.0
36
- */
37
- this.service = ctx.service;
38
- }
39
- }
40
- exports.BaseContextClass = BaseContextClass;
41
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV9jb250ZXh0X2NsYXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2Jhc2VfY29udGV4dF9jbGFzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQTs7OztHQUlHO0FBQ0gsTUFBYSxnQkFBZ0I7SUFDM0IsR0FBRyxDQUFVO0lBQ2IsR0FBRyxDQUFVO0lBQ2IsTUFBTSxDQUFzQjtJQUM1QixPQUFPLENBQW1CO0lBRTFCOztPQUVHO0lBQ0gsWUFBWSxHQUFZO1FBQ3RCOzs7V0FHRztRQUNILElBQUksQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFDO1FBQ2Y7OztXQUdHO1FBQ0gsSUFBSSxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUMsR0FBRyxDQUFDO1FBQ25COzs7V0FHRztRQUNILElBQUksQ0FBQyxNQUFNLEdBQUcsR0FBRyxDQUFDLEdBQUcsQ0FBQyxNQUFNLENBQUM7UUFDN0I7OztXQUdHO1FBQ0gsSUFBSSxDQUFDLE9BQU8sR0FBRyxHQUFHLENBQUMsT0FBTyxDQUFDO0lBQzdCLENBQUM7Q0FDRjtBQS9CRCw0Q0ErQkMifQ==
@@ -1,247 +0,0 @@
1
- import { Application as KoaApplication, Context as KoaContext, Request as KoaRequest, Response as KoaResponse } from '@eggjs/koa';
2
- import type { MiddlewareFunc as KoaMiddlewareFunc, Next } from '@eggjs/koa';
3
- import { EggConsoleLogger, Logger } from 'egg-logger';
4
- import { RegisterOptions, ResourcesController, EggRouter as Router } from '@eggjs/router';
5
- import type { ReadyFunctionArg } from 'get-ready';
6
- import { BaseContextClass } from './base_context_class.js';
7
- import { Timing } from './utils/timing.js';
8
- import type { Fun } from './utils/index.js';
9
- import { Lifecycle } from './lifecycle.js';
10
- import { EggLoader } from './loader/egg_loader.js';
11
- import { EggAppConfig } from './types.js';
12
- import { type SingletonCreateMethod } from './singleton.js';
13
- export declare const EGG_LOADER: unique symbol;
14
- export interface EggCoreOptions {
15
- baseDir: string;
16
- type: 'application' | 'agent';
17
- plugins?: any;
18
- serverScope?: string;
19
- env?: string;
20
- }
21
- export type EggCoreInitOptions = Partial<EggCoreOptions>;
22
- export { KoaRequest, KoaResponse, KoaContext, KoaApplication, Router, };
23
- export type { Next, KoaMiddlewareFunc, };
24
- export declare class Request extends KoaRequest {
25
- app: EggCore;
26
- response: Response;
27
- }
28
- export declare class Response extends KoaResponse {
29
- app: EggCore;
30
- request: Request;
31
- }
32
- export declare class Context extends KoaContext {
33
- app: EggCore;
34
- request: Request;
35
- response: Response;
36
- service: BaseContextClass;
37
- /**
38
- * Returns map of URL parameters for given `path` and `paramNames`.
39
- * @example
40
- * ##### ctx.params.id {string}
41
- *
42
- * `GET /api/users/1` => `'1'`
43
- *
44
- * ##### ctx.params.per_page {string}
45
- *
46
- * The number of every page, `GET /api/users?per_page=20` => `20`
47
- */
48
- params?: Record<string, string>;
49
- /**
50
- * Returns array of router regexp url path captures.
51
- */
52
- captures?: string[];
53
- /**
54
- * Returns the name of the matched router.
55
- */
56
- routerName?: string;
57
- /**
58
- * Returns the path of the matched router.
59
- */
60
- routerPath?: string | RegExp;
61
- }
62
- export type MiddlewareFunc<T = Context> = KoaMiddlewareFunc<T>;
63
- export declare class EggCore extends KoaApplication {
64
- #private;
65
- options: EggCoreOptions;
66
- timing: Timing;
67
- console: EggConsoleLogger;
68
- BaseContextClass: typeof BaseContextClass;
69
- Controller: typeof BaseContextClass;
70
- Service: typeof BaseContextClass;
71
- Helper?: typeof BaseContextClass;
72
- lifecycle: Lifecycle;
73
- loader: EggLoader;
74
- /** auto inject on loadService() */
75
- readonly serviceClasses: Record<string, any>;
76
- /** auto inject on loadController() */
77
- readonly controller: Record<string, any>;
78
- /** auto inject on loadMiddleware() */
79
- readonly middlewares: Record<string, (opt: any, app: EggCore) => MiddlewareFunc>;
80
- /**
81
- * @class
82
- * @param {Object} options - options
83
- * @param {String} [options.baseDir=process.cwd()] - the directory of application
84
- * @param {String} [options.type=application|agent] - whether it's running in app worker or agent worker
85
- * @param {Object} [options.plugins] - custom plugins
86
- * @since 1.0.0
87
- */
88
- constructor(options?: EggCoreInitOptions);
89
- get logger(): Logger;
90
- get coreLogger(): Logger;
91
- /**
92
- * create a singleton instance
93
- * @param {String} name - unique name for singleton
94
- * @param {Function|AsyncFunction} create - method will be invoked when singleton instance create
95
- */
96
- addSingleton(name: string, create: SingletonCreateMethod): void;
97
- /**
98
- * override koa's app.use, support generator function
99
- * @since 1.0.0
100
- */
101
- use(fn: MiddlewareFunc): this;
102
- /**
103
- * Whether `application` or `agent`
104
- * @member {String}
105
- * @since 1.0.0
106
- */
107
- get type(): "application" | "agent";
108
- /**
109
- * The current directory of application
110
- * @member {String}
111
- * @see {@link AppInfo#baseDir}
112
- * @since 1.0.0
113
- */
114
- get baseDir(): string;
115
- /**
116
- * Alias to {@link https://npmjs.com/package/depd}
117
- * @member {Function}
118
- * @since 1.0.0
119
- */
120
- get deprecate(): (message: string) => void;
121
- /**
122
- * The name of application
123
- * @member {String}
124
- * @see {@link AppInfo#name}
125
- * @since 1.0.0
126
- */
127
- get name(): any;
128
- /**
129
- * Retrieve enabled plugins
130
- * @member {Object}
131
- * @since 1.0.0
132
- */
133
- get plugins(): Record<string, import("./types.js").EggPluginInfo>;
134
- /**
135
- * The configuration of application
136
- * @member {Config}
137
- * @since 1.0.0
138
- */
139
- get config(): EggAppConfig;
140
- /**
141
- * Execute scope after loaded and before app start.
142
- *
143
- * Notice:
144
- * This method is now NOT recommended and regarded as a deprecated one,
145
- * For plugin development, we should use `didLoad` instead.
146
- * For application development, we should use `willReady` instead.
147
- *
148
- * @see https://eggjs.org/en/advanced/loader.html#beforestart
149
- *
150
- * @param {Function} scope function will execute before app start
151
- * @param {string} [name] scope name, default is empty string
152
- */
153
- beforeStart(scope: Fun, name?: string): void;
154
- /**
155
- * register an callback function that will be invoked when application is ready.
156
- * @see https://github.com/node-modules/get-ready
157
- * @since 1.0.0
158
- * @example
159
- * const app = new Application(...);
160
- * app.ready(err => {
161
- * if (err) throw err;
162
- * console.log('done');
163
- * });
164
- */
165
- ready(): Promise<void>;
166
- ready(flagOrFunction: ReadyFunctionArg): void;
167
- /**
168
- * If a client starts asynchronously, you can register `readyCallback`,
169
- * then the application will wait for the callback to ready
170
- *
171
- * It will log when the callback is not invoked after 10s
172
- *
173
- * Recommend to use {@link EggCore#beforeStart}
174
- * @since 1.0.0
175
- *
176
- * @param {String} name - readyCallback task name
177
- * @param {object} opts -
178
- * - {Number} [timeout=10000] - emit `ready_timeout` when it doesn't finish but reach the timeout
179
- * - {Boolean} [isWeakDep=false] - whether it's a weak dependency
180
- * @return {Function} - a callback
181
- * @example
182
- * const done = app.readyCallback('mysql');
183
- * mysql.ready(done);
184
- */
185
- readyCallback(name: string, opts: object): (...args: any[]) => void;
186
- /**
187
- * Register a function that will be called when app close.
188
- *
189
- * Notice:
190
- * This method is now NOT recommended directly used,
191
- * Developers SHOULDN'T use app.beforeClose directly now,
192
- * but in the form of class to implement beforeClose instead.
193
- *
194
- * @see https://eggjs.org/en/advanced/loader.html#beforeclose
195
- *
196
- * @param {Function} fn - the function that can be generator function or async function.
197
- */
198
- beforeClose(fn: Fun, name?: string): void;
199
- /**
200
- * Close all, it will close
201
- * - callbacks registered by beforeClose
202
- * - emit `close` event
203
- * - remove add listeners
204
- *
205
- * If error is thrown when it's closing, the promise will reject.
206
- * It will also reject after following call.
207
- * @return {Promise} promise
208
- * @since 1.0.0
209
- */
210
- close(): Promise<void>;
211
- /**
212
- * get router
213
- * @member {Router} EggCore#router
214
- * @since 1.0.0
215
- */
216
- get router(): Router;
217
- /**
218
- * Alias to {@link Router#url}
219
- * @param {String} name - Router name
220
- * @param {Object} params - more parameters
221
- * @return {String} url
222
- */
223
- url(name: string, params?: any): string;
224
- head(path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
225
- head(name: string, path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
226
- get(path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
227
- get(name: string, path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
228
- put(path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
229
- put(name: string, path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
230
- patch(path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
231
- patch(name: string, path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
232
- post(path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
233
- post(name: string, path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
234
- delete(path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
235
- delete(name: string, path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
236
- del(path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
237
- del(name: string, path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
238
- all(path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
239
- all(name: string, path: string | RegExp | (string | RegExp)[], ...middlewares: (MiddlewareFunc | string)[]): EggCore;
240
- resources(prefix: string, controller: string | ResourcesController): EggCore;
241
- resources(prefix: string, middleware: MiddlewareFunc, controller: string | ResourcesController): EggCore;
242
- resources(name: string, prefix: string, controller: string | ResourcesController): EggCore;
243
- resources(name: string, prefix: string, middleware: MiddlewareFunc, controller: string | ResourcesController): EggCore;
244
- redirect(source: string, destination: string, status?: number): this;
245
- register(path: string | RegExp | (string | RegExp)[], methods: string[], middleware: MiddlewareFunc | MiddlewareFunc[], opts?: RegisterOptions): this;
246
- get [EGG_LOADER](): typeof EggLoader;
247
- }