egg 4.1.2-beta.6 → 4.1.2-beta.8
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/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/lib/core/httpclient.js +4 -0
- package/dist/lib/core/utils.d.ts +26 -1
- package/dist/lib/core/utils.js +71 -1
- package/dist/lib/egg.d.ts +12 -0
- package/dist/lib/egg.js +31 -4
- package/dist/lib/loader/AppWorkerLoader.js +1 -1
- package/dist/lib/start.d.ts +2 -0
- package/dist/lib/start.js +12 -5
- package/dist/lib/types.d.ts +19 -1
- package/package.json +33 -33
package/dist/index.d.ts
CHANGED
|
@@ -16,9 +16,10 @@ import { SingleModeAgent, SingleModeApplication, StartEggOptions, startEgg } fro
|
|
|
16
16
|
import { EggConfigFactory, EggPluginFactory, EggPluginMeta, EggPluginOptions, PartialEggConfig, defineConfig, defineConfigFactory, definePluginFactory } from "./lib/define.js";
|
|
17
17
|
import { CookieLimitExceedError } from "./lib/error/CookieLimitExceedError.js";
|
|
18
18
|
import { MessageUnhandledRejectionError } from "./lib/error/MessageUnhandledRejectionError.js";
|
|
19
|
+
import { CreateTransparentProxyOptions, createTransparentProxy } from "./lib/core/utils.js";
|
|
19
20
|
import { BaseHookClass } from "./lib/core/base_hook_class.js";
|
|
20
21
|
import { Singleton, SingletonCreateMethod, SingletonOptions } from "@eggjs/core";
|
|
21
22
|
import { EggLogger, EggLogger as Logger, LoggerLevel } from "egg-logger";
|
|
22
23
|
import { AccessLevel, Acl, BackgroundTaskHelper, ContextEventBus, ContextProto, Cookies, EggObjectFactory, EggObjectLifecycle, EggProtoImplClass, EggQualifier, EggType, Event, EventBus, EventContext, Events, HTTPBody, HTTPContext, HTTPController, HTTPCookies, HTTPHeaders, HTTPMethod, HTTPMethodEnum, HTTPParam, HTTPParamType, HTTPQueries, HTTPQuery, HTTPRequest, Host, ImplDecorator, IncomingHttpHeaders, Inject, InjectOptional, LifecycleDestroy, LifecycleInit, LifecyclePostConstruct, LifecyclePostInject, LifecyclePreDestroy, LifecyclePreInject, LifecyclePreLoad, MetadataUtil, Middleware, MultiInstanceProto, MultiInstancePrototypeGetObjectsContext, ObjectInfo, ObjectInitType, ObjectInitTypeLike, QualifierImplDecoratorUtil, QualifierUtil, SingletonProto } from "@eggjs/tegg";
|
|
23
24
|
export * from "@eggjs/cluster";
|
|
24
|
-
export { AccessLevel, Acl, Agent, AgentWorkerLoader, AppWorkerLoader, Application, BackgroundTaskHelper, BaseContextClass, BaseHookClass as Boot, ClientErrorResponse, type EggAppConfig as Config, Context, type ContextEventBus, ContextHttpClient, ContextProto, BaseContextClass as Controller, BaseContextClass as Service, BaseContextClass as Subscription, CookieLimitExceedError, Cookies, CustomLoaderConfig, EggAppConfig, EggAppInfo, EggApplicationCore, EggApplicationCoreOptions, EggConfigFactory, EggContext, HttpClient as EggContextHttpClient, HttpClient as EggHttpClient, HttpClient, EggEnvType, type EggLogger, EggLoggerConfig, type EggObjectFactory, type EggObjectLifecycle, EggPlugin, EggPluginFactory, EggPluginItem, EggPluginMeta, EggPluginOptions, type EggProtoImplClass, EggQualifier, EggType, Event, type EventBus, EventContext, type Events, HTTPBody, HTTPContext, HTTPController, HTTPCookies, HTTPHeaders, HTTPMethod, HTTPMethodEnum, HTTPParam, HTTPParamType, HTTPQueries, HTTPQuery, HTTPRequest, Helper, type Helper as IHelper, Host, HttpClientConfig, HttpClientOptions, HttpClientRequestOptions, HttpClientRequestURL, HttpClientResponse, ILifecycleBoot as IBoot, ILifecycleBoot, IController, IEggPluginItem, IService, type ImplDecorator, type IncomingHttpHeaders, Inject, InjectOptional, LifecycleDestroy, LifecycleInit, LifecyclePostConstruct, LifecyclePostInject, LifecyclePreDestroy, LifecyclePreInject, LifecyclePreLoad, type Logger, type LoggerLevel, MessageUnhandledRejectionError, MetadataUtil, Middleware, MiddlewareFunc, MultiInstanceProto, type MultiInstancePrototypeGetObjectsContext, Next, type ObjectInfo, ObjectInitType, type ObjectInitTypeLike, PartialDeep, PartialEggConfig, PowerPartial, QualifierImplDecoratorUtil, QualifierUtil, Request, RequestObjectBody, Response, Router, type SingleModeAgent, type SingleModeApplication, Singleton, type SingletonCreateMethod, type SingletonOptions, SingletonProto, StartEggOptions, defineConfig, defineConfigFactory, definePluginFactory, startEgg as start, startEgg };
|
|
25
|
+
export { AccessLevel, Acl, Agent, AgentWorkerLoader, AppWorkerLoader, Application, BackgroundTaskHelper, BaseContextClass, BaseHookClass as Boot, ClientErrorResponse, type EggAppConfig as Config, Context, type ContextEventBus, ContextHttpClient, ContextProto, BaseContextClass as Controller, BaseContextClass as Service, BaseContextClass as Subscription, CookieLimitExceedError, Cookies, type CreateTransparentProxyOptions, CustomLoaderConfig, EggAppConfig, EggAppInfo, EggApplicationCore, EggApplicationCoreOptions, EggConfigFactory, EggContext, HttpClient as EggContextHttpClient, HttpClient as EggHttpClient, HttpClient, EggEnvType, type EggLogger, EggLoggerConfig, type EggObjectFactory, type EggObjectLifecycle, EggPlugin, EggPluginFactory, EggPluginItem, EggPluginMeta, EggPluginOptions, type EggProtoImplClass, EggQualifier, EggType, Event, type EventBus, EventContext, type Events, HTTPBody, HTTPContext, HTTPController, HTTPCookies, HTTPHeaders, HTTPMethod, HTTPMethodEnum, HTTPParam, HTTPParamType, HTTPQueries, HTTPQuery, HTTPRequest, Helper, type Helper as IHelper, Host, HttpClientConfig, HttpClientOptions, HttpClientRequestOptions, HttpClientRequestURL, HttpClientResponse, ILifecycleBoot as IBoot, ILifecycleBoot, IController, IEggPluginItem, IService, type ImplDecorator, type IncomingHttpHeaders, Inject, InjectOptional, LifecycleDestroy, LifecycleInit, LifecyclePostConstruct, LifecyclePostInject, LifecyclePreDestroy, LifecyclePreInject, LifecyclePreLoad, type Logger, type LoggerLevel, MessageUnhandledRejectionError, MetadataUtil, Middleware, MiddlewareFunc, MultiInstanceProto, type MultiInstancePrototypeGetObjectsContext, Next, type ObjectInfo, ObjectInitType, type ObjectInitTypeLike, PartialDeep, PartialEggConfig, PowerPartial, QualifierImplDecoratorUtil, QualifierUtil, Request, RequestObjectBody, Response, Router, type SingleModeAgent, type SingleModeApplication, Singleton, type SingletonCreateMethod, type SingletonOptions, SingletonProto, StartEggOptions, createTransparentProxy, defineConfig, defineConfigFactory, definePluginFactory, startEgg as start, startEgg };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { ContextHttpClient } from "./lib/core/context_httpclient.js";
|
|
|
8
8
|
import { HttpClient } from "./lib/core/httpclient.js";
|
|
9
9
|
import { CookieLimitExceedError } from "./lib/error/CookieLimitExceedError.js";
|
|
10
10
|
import { MessageUnhandledRejectionError } from "./lib/error/MessageUnhandledRejectionError.js";
|
|
11
|
+
import { createTransparentProxy } from "./lib/core/utils.js";
|
|
11
12
|
import { EggApplicationCore, Router } from "./lib/egg.js";
|
|
12
13
|
import { AppWorkerLoader } from "./lib/loader/AppWorkerLoader.js";
|
|
13
14
|
import { AgentWorkerLoader } from "./lib/loader/AgentWorkerLoader.js";
|
|
@@ -22,4 +23,4 @@ import { AccessLevel, Acl, BackgroundTaskHelper, ContextProto, Cookies, EggQuali
|
|
|
22
23
|
|
|
23
24
|
export * from "@eggjs/cluster"
|
|
24
25
|
|
|
25
|
-
export { AccessLevel, Acl, Agent, AgentWorkerLoader, AppWorkerLoader, Application, BackgroundTaskHelper, BaseContextClass, BaseHookClass as Boot, Context, ContextHttpClient, ContextProto, BaseContextClass as Controller, BaseContextClass as Service, BaseContextClass as Subscription, CookieLimitExceedError, Cookies, EggApplicationCore, EggQualifier, EggType, Event, EventContext, HTTPBody, HTTPContext, HTTPController, HTTPCookies, HTTPHeaders, HTTPMethod, HTTPMethodEnum, HTTPParam, HTTPParamType, HTTPQueries, HTTPQuery, HTTPRequest, Helper, Host, HttpClient, Inject, InjectOptional, LifecycleDestroy, LifecycleInit, LifecyclePostConstruct, LifecyclePostInject, LifecyclePreDestroy, LifecyclePreInject, LifecyclePreLoad, MessageUnhandledRejectionError, MetadataUtil, Middleware, MultiInstanceProto, ObjectInitType, QualifierImplDecoratorUtil, QualifierUtil, Request, Response, Router, Singleton, SingletonProto, defineConfig, defineConfigFactory, definePluginFactory, startEgg as start, startEgg };
|
|
26
|
+
export { AccessLevel, Acl, Agent, AgentWorkerLoader, AppWorkerLoader, Application, BackgroundTaskHelper, BaseContextClass, BaseHookClass as Boot, Context, ContextHttpClient, ContextProto, BaseContextClass as Controller, BaseContextClass as Service, BaseContextClass as Subscription, CookieLimitExceedError, Cookies, EggApplicationCore, EggQualifier, EggType, Event, EventContext, HTTPBody, HTTPContext, HTTPController, HTTPCookies, HTTPHeaders, HTTPMethod, HTTPMethodEnum, HTTPParam, HTTPParamType, HTTPQueries, HTTPQuery, HTTPRequest, Helper, Host, HttpClient, Inject, InjectOptional, LifecycleDestroy, LifecycleInit, LifecyclePostConstruct, LifecyclePostInject, LifecyclePreDestroy, LifecyclePreInject, LifecyclePreLoad, MessageUnhandledRejectionError, MetadataUtil, Middleware, MultiInstanceProto, ObjectInitType, QualifierImplDecoratorUtil, QualifierUtil, Request, Response, Router, Singleton, SingletonProto, createTransparentProxy, defineConfig, defineConfigFactory, definePluginFactory, startEgg as start, startEgg };
|
|
@@ -17,6 +17,10 @@ var HttpClient = class extends HttpClient$1 {
|
|
|
17
17
|
};
|
|
18
18
|
super(initOptions);
|
|
19
19
|
this.#app = app;
|
|
20
|
+
if (config.interceptors?.length) {
|
|
21
|
+
const originalDispatcher = this.getDispatcher();
|
|
22
|
+
this.setDispatcher(originalDispatcher.compose(...config.interceptors));
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
async request(url, options) {
|
|
22
26
|
options = options ?? {};
|
package/dist/lib/core/utils.d.ts
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
//#region src/lib/core/utils.d.ts
|
|
2
2
|
declare function convertObject(obj: any, ignore?: string | RegExp | (string | RegExp)[]): any;
|
|
3
3
|
declare function safeParseURL(url: string): URL | null;
|
|
4
|
+
interface CreateTransparentProxyOptions<T> {
|
|
5
|
+
/**
|
|
6
|
+
* Factory function to lazily create the real object.
|
|
7
|
+
* Called at most once, on first property access.
|
|
8
|
+
*/
|
|
9
|
+
createReal: () => T;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to bind functions from the real object to the real instance.
|
|
12
|
+
* Defaults to true.
|
|
13
|
+
*/
|
|
14
|
+
bindFunctions?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a Proxy that behaves like the real object, but remains transparent to
|
|
18
|
+
* monkeypatch libraries (e.g. defineProperty-based overrides like egg-mock's `mm()`).
|
|
19
|
+
*
|
|
20
|
+
* - Lazily creates the real object on first access.
|
|
21
|
+
* - Allows overriding properties on the proxy target (overlay) — e.g. via `Object.defineProperty`.
|
|
22
|
+
* - Delegates everything else to the real object.
|
|
23
|
+
*
|
|
24
|
+
* This is used to defer HttpClient construction so plugins can modify
|
|
25
|
+
* `config.httpclient.lookup` after the first access to `app.httpClient` but
|
|
26
|
+
* before any actual HTTP request is made.
|
|
27
|
+
*/
|
|
28
|
+
declare function createTransparentProxy<T extends object>(options: CreateTransparentProxyOptions<T>): T;
|
|
4
29
|
//#endregion
|
|
5
|
-
export { convertObject, safeParseURL };
|
|
30
|
+
export { CreateTransparentProxyOptions, convertObject, createTransparentProxy, safeParseURL };
|
package/dist/lib/core/utils.js
CHANGED
|
@@ -43,6 +43,76 @@ function safeParseURL(url) {
|
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a Proxy that behaves like the real object, but remains transparent to
|
|
48
|
+
* monkeypatch libraries (e.g. defineProperty-based overrides like egg-mock's `mm()`).
|
|
49
|
+
*
|
|
50
|
+
* - Lazily creates the real object on first access.
|
|
51
|
+
* - Allows overriding properties on the proxy target (overlay) — e.g. via `Object.defineProperty`.
|
|
52
|
+
* - Delegates everything else to the real object.
|
|
53
|
+
*
|
|
54
|
+
* This is used to defer HttpClient construction so plugins can modify
|
|
55
|
+
* `config.httpclient.lookup` after the first access to `app.httpClient` but
|
|
56
|
+
* before any actual HTTP request is made.
|
|
57
|
+
*/
|
|
58
|
+
function createTransparentProxy(options) {
|
|
59
|
+
const { createReal, bindFunctions = true } = options;
|
|
60
|
+
if (typeof createReal !== "function") throw new TypeError("createReal must be a function");
|
|
61
|
+
let real;
|
|
62
|
+
let cachedError;
|
|
63
|
+
const boundFnCache = /* @__PURE__ */ new WeakMap();
|
|
64
|
+
const getReal = () => {
|
|
65
|
+
if (real) return real;
|
|
66
|
+
if (cachedError) throw cachedError;
|
|
67
|
+
try {
|
|
68
|
+
return real = createReal();
|
|
69
|
+
} catch (err) {
|
|
70
|
+
cachedError = err;
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const hasOwn = (obj, prop) => Reflect.getOwnPropertyDescriptor(obj, prop) !== void 0;
|
|
75
|
+
return new Proxy({}, {
|
|
76
|
+
get(target, prop, receiver) {
|
|
77
|
+
const r = getReal();
|
|
78
|
+
if (hasOwn(target, prop)) return Reflect.get(target, prop, receiver);
|
|
79
|
+
const value = Reflect.get(r, prop);
|
|
80
|
+
if (bindFunctions && typeof value === "function") {
|
|
81
|
+
let bound = boundFnCache.get(value);
|
|
82
|
+
if (!bound) {
|
|
83
|
+
bound = value.bind(r);
|
|
84
|
+
boundFnCache.set(value, bound);
|
|
85
|
+
}
|
|
86
|
+
return bound;
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
89
|
+
},
|
|
90
|
+
set(target, prop, value) {
|
|
91
|
+
const r = getReal();
|
|
92
|
+
if (hasOwn(target, prop)) return Reflect.set(target, prop, value);
|
|
93
|
+
return Reflect.set(r, prop, value);
|
|
94
|
+
},
|
|
95
|
+
has(target, prop) {
|
|
96
|
+
return Reflect.has(target, prop) || Reflect.has(getReal(), prop);
|
|
97
|
+
},
|
|
98
|
+
ownKeys(target) {
|
|
99
|
+
return [...new Set([...Reflect.ownKeys(getReal()), ...Reflect.ownKeys(target)])];
|
|
100
|
+
},
|
|
101
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
102
|
+
return Reflect.getOwnPropertyDescriptor(target, prop) ?? Reflect.getOwnPropertyDescriptor(getReal(), prop);
|
|
103
|
+
},
|
|
104
|
+
deleteProperty(target, prop) {
|
|
105
|
+
if (hasOwn(target, prop)) return Reflect.deleteProperty(target, prop);
|
|
106
|
+
return Reflect.deleteProperty(getReal(), prop);
|
|
107
|
+
},
|
|
108
|
+
getPrototypeOf() {
|
|
109
|
+
return Reflect.getPrototypeOf(getReal());
|
|
110
|
+
},
|
|
111
|
+
defineProperty(target, prop, descriptor) {
|
|
112
|
+
return Reflect.defineProperty(target, prop, descriptor);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
46
116
|
|
|
47
117
|
//#endregion
|
|
48
|
-
export { convertObject, safeParseURL };
|
|
118
|
+
export { convertObject, createTransparentProxy, safeParseURL };
|
package/dist/lib/egg.d.ts
CHANGED
|
@@ -194,6 +194,13 @@ declare class EggApplicationCore extends EggCore {
|
|
|
194
194
|
createHttpClient(options?: HttpClientOptions): HttpClient;
|
|
195
195
|
/**
|
|
196
196
|
* HttpClient instance
|
|
197
|
+
*
|
|
198
|
+
* Returns a transparent proxy that defers actual HttpClient construction
|
|
199
|
+
* until a method/property is first accessed. This allows plugins to modify
|
|
200
|
+
* `config.httpclient.lookup` or other options during lifecycle hooks
|
|
201
|
+
* (e.g. `configWillLoad`, `didLoad`) even after `app.httpClient` is
|
|
202
|
+
* first referenced.
|
|
203
|
+
*
|
|
197
204
|
* @see https://github.com/node-modules/urllib
|
|
198
205
|
* @member {HttpClient}
|
|
199
206
|
*/
|
|
@@ -244,6 +251,11 @@ declare class EggApplicationCore extends EggCore {
|
|
|
244
251
|
*/
|
|
245
252
|
dumpConfig(): void;
|
|
246
253
|
dumpTiming(): void;
|
|
254
|
+
/**
|
|
255
|
+
* Generate and save startup manifest for faster subsequent startups.
|
|
256
|
+
* Only generates when no valid manifest was loaded (avoids overwriting during manifest-accelerated starts).
|
|
257
|
+
*/
|
|
258
|
+
dumpManifest(): void;
|
|
247
259
|
protected customEggPaths(): string[];
|
|
248
260
|
get config(): EggAppConfig$1;
|
|
249
261
|
/**
|
package/dist/lib/egg.js
CHANGED
|
@@ -7,9 +7,9 @@ import { ContextHttpClient } from "./core/context_httpclient.js";
|
|
|
7
7
|
import { HttpClient } from "./core/httpclient.js";
|
|
8
8
|
import { createLoggers } from "./core/logger.js";
|
|
9
9
|
import { create } from "./core/messenger/index.js";
|
|
10
|
-
import { convertObject } from "./core/utils.js";
|
|
10
|
+
import { convertObject, createTransparentProxy } from "./core/utils.js";
|
|
11
11
|
import assert from "node:assert";
|
|
12
|
-
import { EggCore, Router, utils } from "@eggjs/core";
|
|
12
|
+
import { EggCore, ManifestStore, Router, utils } from "@eggjs/core";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import fs from "node:fs";
|
|
15
15
|
import http from "node:http";
|
|
@@ -127,6 +127,8 @@ var EggApplicationCore = class extends EggCore {
|
|
|
127
127
|
const dumpStartTime = Date.now();
|
|
128
128
|
this.dumpConfig();
|
|
129
129
|
this.dumpTiming();
|
|
130
|
+
this.dumpManifest();
|
|
131
|
+
ManifestStore.flushCompileCache();
|
|
130
132
|
this.coreLogger.info("[egg] dump config after ready, %sms", Date.now() - dumpStartTime);
|
|
131
133
|
}));
|
|
132
134
|
this.#setupTimeoutTimer();
|
|
@@ -139,7 +141,8 @@ var EggApplicationCore = class extends EggCore {
|
|
|
139
141
|
this.lifecycle.registerBeforeClose(async () => {
|
|
140
142
|
for (const clusterClient of this.#clusterClients) await close(clusterClient);
|
|
141
143
|
this.#clusterClients = [];
|
|
142
|
-
if (this.type === "application" && this.options.mode === "single") await this.agent
|
|
144
|
+
if (this.type === "application" && this.options.mode === "single") await this.agent?.close();
|
|
145
|
+
ManifestStore.flushCompileCache();
|
|
143
146
|
for (const logger of this.loggers.values()) logger.close();
|
|
144
147
|
this.messenger.close();
|
|
145
148
|
process.removeListener("unhandledRejection", this._unhandledRejectionHandler);
|
|
@@ -282,11 +285,18 @@ var EggApplicationCore = class extends EggCore {
|
|
|
282
285
|
}
|
|
283
286
|
/**
|
|
284
287
|
* HttpClient instance
|
|
288
|
+
*
|
|
289
|
+
* Returns a transparent proxy that defers actual HttpClient construction
|
|
290
|
+
* until a method/property is first accessed. This allows plugins to modify
|
|
291
|
+
* `config.httpclient.lookup` or other options during lifecycle hooks
|
|
292
|
+
* (e.g. `configWillLoad`, `didLoad`) even after `app.httpClient` is
|
|
293
|
+
* first referenced.
|
|
294
|
+
*
|
|
285
295
|
* @see https://github.com/node-modules/urllib
|
|
286
296
|
* @member {HttpClient}
|
|
287
297
|
*/
|
|
288
298
|
get httpClient() {
|
|
289
|
-
if (!this.#httpClient) this.#httpClient = this.createHttpClient();
|
|
299
|
+
if (!this.#httpClient) this.#httpClient = createTransparentProxy({ createReal: () => this.createHttpClient() });
|
|
290
300
|
return this.#httpClient;
|
|
291
301
|
}
|
|
292
302
|
/**
|
|
@@ -397,6 +407,23 @@ var EggApplicationCore = class extends EggCore {
|
|
|
397
407
|
this.coreLogger.warn(`[egg] dumpTiming error: ${err.message}`);
|
|
398
408
|
}
|
|
399
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* Generate and save startup manifest for faster subsequent startups.
|
|
412
|
+
* Only generates when no valid manifest was loaded (avoids overwriting during manifest-accelerated starts).
|
|
413
|
+
*/
|
|
414
|
+
dumpManifest() {
|
|
415
|
+
try {
|
|
416
|
+
if (this.loader.serverEnv === "local" && process.env.EGG_MANIFEST !== "true") return;
|
|
417
|
+
if (this.loader.manifest.data.generatedAt) return;
|
|
418
|
+
const manifest = this.loader.generateManifest();
|
|
419
|
+
ManifestStore.enableCompileCache(this.baseDir);
|
|
420
|
+
ManifestStore.write(this.baseDir, manifest).catch((err) => {
|
|
421
|
+
this.coreLogger.warn("[egg] dumpManifest write error: %s", err.message);
|
|
422
|
+
});
|
|
423
|
+
} catch (err) {
|
|
424
|
+
this.coreLogger.warn("[egg] dumpManifest error: %s", err.message);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
400
427
|
customEggPaths() {
|
|
401
428
|
return [path.dirname(import.meta.dirname), ...super.customEggPaths()];
|
|
402
429
|
}
|
package/dist/lib/start.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ interface StartEggOptions {
|
|
|
13
13
|
mode?: "single";
|
|
14
14
|
env?: string;
|
|
15
15
|
plugins?: EggPlugin;
|
|
16
|
+
/** Skip lifecycle hooks, only trigger loadMetadata for manifest generation */
|
|
17
|
+
metadataOnly?: boolean;
|
|
16
18
|
}
|
|
17
19
|
interface SingleModeApplication extends Application {
|
|
18
20
|
agent: SingleModeAgent;
|
package/dist/lib/start.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Agent } from "./agent.js";
|
|
2
2
|
import { Application } from "./application.js";
|
|
3
3
|
import "./types.js";
|
|
4
|
+
import { ManifestStore } from "@eggjs/core";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import { importModule } from "@eggjs/utils";
|
|
6
7
|
import { readJSON } from "utility";
|
|
@@ -12,6 +13,7 @@ import { readJSON } from "utility";
|
|
|
12
13
|
async function startEgg(options = {}) {
|
|
13
14
|
options.baseDir = options.baseDir ?? process.cwd();
|
|
14
15
|
options.mode = "single";
|
|
16
|
+
ManifestStore.enableCompileCache(options.baseDir);
|
|
15
17
|
if (!options.framework) try {
|
|
16
18
|
options.framework = (await readJSON(path.join(options.baseDir, "package.json"))).egg.framework;
|
|
17
19
|
} catch {}
|
|
@@ -22,13 +24,18 @@ async function startEgg(options = {}) {
|
|
|
22
24
|
AgentClass = framework.Agent;
|
|
23
25
|
ApplicationClass = framework.Application;
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
let agent;
|
|
28
|
+
if (!options.metadataOnly) {
|
|
29
|
+
agent = new AgentClass({ ...options });
|
|
30
|
+
await agent.ready();
|
|
31
|
+
}
|
|
27
32
|
const application = new ApplicationClass({ ...options });
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
if (agent) {
|
|
34
|
+
application.agent = agent;
|
|
35
|
+
agent.application = application;
|
|
36
|
+
}
|
|
30
37
|
await application.ready();
|
|
31
|
-
application.messenger.broadcast("egg-ready");
|
|
38
|
+
if (!options.metadataOnly) application.messenger.broadcast("egg-ready");
|
|
32
39
|
return application;
|
|
33
40
|
}
|
|
34
41
|
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import "./egg.js";
|
|
|
7
7
|
import { Application } from "./application.js";
|
|
8
8
|
import { EggAppConfig as EggAppConfig$1, EggAppInfo, FileLoaderOptions } from "@eggjs/core";
|
|
9
9
|
import { EggLoggerOptions, EggLoggersOptions } from "egg-logger";
|
|
10
|
-
import { RequestOptions } from "urllib";
|
|
10
|
+
import { Dispatcher, RequestOptions } from "urllib";
|
|
11
11
|
import { LookupFunction, Socket } from "node:net";
|
|
12
12
|
import { PartialDeep } from "type-fest";
|
|
13
13
|
|
|
@@ -61,6 +61,24 @@ interface HttpClientConfig {
|
|
|
61
61
|
*/
|
|
62
62
|
allowH2?: boolean;
|
|
63
63
|
lookup?: LookupFunction;
|
|
64
|
+
/**
|
|
65
|
+
* Interceptors for request composition, applied via `Dispatcher.compose()`.
|
|
66
|
+
* Each interceptor receives a `dispatch` function and returns a new `dispatch` function.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* // config.default.ts
|
|
71
|
+
* config.httpclient = {
|
|
72
|
+
* interceptors: [
|
|
73
|
+
* (dispatch) => (opts, handler) => {
|
|
74
|
+
* opts.headers = { ...opts.headers, 'x-trace-id': generateTraceId() };
|
|
75
|
+
* return dispatch(opts, handler);
|
|
76
|
+
* },
|
|
77
|
+
* ],
|
|
78
|
+
* };
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
interceptors?: Dispatcher.DispatcherComposeInterceptor[];
|
|
64
82
|
}
|
|
65
83
|
/**
|
|
66
84
|
* Powerful Partial, Support adding ? modifier to a mapped property in deep level
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "egg",
|
|
3
|
-
"version": "4.1.2-beta.
|
|
3
|
+
"version": "4.1.2-beta.8",
|
|
4
4
|
"description": "A web application framework for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -98,34 +98,34 @@
|
|
|
98
98
|
"type-fest": "^5.0.1",
|
|
99
99
|
"urllib": "^4.8.2",
|
|
100
100
|
"utility": "^2.5.0",
|
|
101
|
-
"@eggjs/
|
|
102
|
-
"@eggjs/
|
|
103
|
-
"@eggjs/cluster": "4.0.2-beta.
|
|
104
|
-
"@eggjs/controller-plugin": "4.0.2-beta.
|
|
105
|
-
"@eggjs/
|
|
106
|
-
"@eggjs/
|
|
107
|
-
"@eggjs/
|
|
108
|
-
"@eggjs/development": "5.0.2-beta.
|
|
109
|
-
"@eggjs/
|
|
110
|
-
"@eggjs/
|
|
111
|
-
"@eggjs/
|
|
112
|
-
"@eggjs/
|
|
113
|
-
"@eggjs/
|
|
114
|
-
"@eggjs/
|
|
115
|
-
"@eggjs/multipart": "5.0.2-beta.
|
|
116
|
-
"@eggjs/
|
|
117
|
-
"@eggjs/
|
|
118
|
-
"@eggjs/
|
|
119
|
-
"@eggjs/
|
|
120
|
-
"@eggjs/
|
|
121
|
-
"@eggjs/
|
|
122
|
-
"@eggjs/tegg
|
|
123
|
-
"@eggjs/
|
|
124
|
-
"@eggjs/
|
|
125
|
-
"@eggjs/
|
|
126
|
-
"@eggjs/
|
|
127
|
-
"@eggjs/
|
|
128
|
-
"@eggjs/
|
|
101
|
+
"@eggjs/ajv-plugin": "4.0.2-beta.8",
|
|
102
|
+
"@eggjs/aop-plugin": "4.0.2-beta.8",
|
|
103
|
+
"@eggjs/cluster": "4.0.2-beta.8",
|
|
104
|
+
"@eggjs/controller-plugin": "4.0.2-beta.8",
|
|
105
|
+
"@eggjs/core": "7.0.2-beta.8",
|
|
106
|
+
"@eggjs/dal-plugin": "4.0.2-beta.8",
|
|
107
|
+
"@eggjs/cookies": "4.0.2-beta.8",
|
|
108
|
+
"@eggjs/development": "5.0.2-beta.8",
|
|
109
|
+
"@eggjs/eventbus-plugin": "4.0.2-beta.8",
|
|
110
|
+
"@eggjs/i18n": "4.0.2-beta.8",
|
|
111
|
+
"@eggjs/errors": "3.0.2-beta.8",
|
|
112
|
+
"@eggjs/extend2": "5.0.2-beta.8",
|
|
113
|
+
"@eggjs/jsonp": "4.0.2-beta.8",
|
|
114
|
+
"@eggjs/logrotator": "5.0.2-beta.8",
|
|
115
|
+
"@eggjs/multipart": "5.0.2-beta.8",
|
|
116
|
+
"@eggjs/onerror": "4.0.2-beta.8",
|
|
117
|
+
"@eggjs/orm-plugin": "4.0.2-beta.8",
|
|
118
|
+
"@eggjs/schedule": "6.0.2-beta.8",
|
|
119
|
+
"@eggjs/schedule-plugin": "4.0.2-beta.8",
|
|
120
|
+
"@eggjs/security": "5.0.2-beta.8",
|
|
121
|
+
"@eggjs/session": "5.0.2-beta.8",
|
|
122
|
+
"@eggjs/tegg": "4.0.2-beta.8",
|
|
123
|
+
"@eggjs/tegg-config": "4.0.2-beta.8",
|
|
124
|
+
"@eggjs/tegg-plugin": "4.0.2-beta.8",
|
|
125
|
+
"@eggjs/utils": "5.0.2-beta.8",
|
|
126
|
+
"@eggjs/view": "4.0.2-beta.8",
|
|
127
|
+
"@eggjs/static": "4.0.2-beta.8",
|
|
128
|
+
"@eggjs/watcher": "5.0.2-beta.8"
|
|
129
129
|
},
|
|
130
130
|
"devDependencies": {
|
|
131
131
|
"@types/koa-bodyparser": "^4.3.12",
|
|
@@ -141,10 +141,10 @@
|
|
|
141
141
|
"sdk-base": "^5.0.1",
|
|
142
142
|
"spy": "^1.0.0",
|
|
143
143
|
"typescript": "^5.9.3",
|
|
144
|
-
"@eggjs/koa": "3.1.2-beta.
|
|
145
|
-
"@eggjs/
|
|
146
|
-
"@eggjs/
|
|
147
|
-
"@eggjs/
|
|
144
|
+
"@eggjs/koa": "3.1.2-beta.8",
|
|
145
|
+
"@eggjs/supertest": "9.0.2-beta.8",
|
|
146
|
+
"@eggjs/tracer": "4.0.2-beta.8",
|
|
147
|
+
"@eggjs/mock": "7.0.2-beta.8"
|
|
148
148
|
},
|
|
149
149
|
"engines": {
|
|
150
150
|
"node": ">=22.18.0"
|