egg 4.1.2-beta.7 → 4.1.2-beta.9
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 +7 -0
- package/dist/lib/egg.js +12 -2
- package/dist/lib/start.js +2 -0
- 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
|
*/
|
package/dist/lib/egg.js
CHANGED
|
@@ -7,7 +7,7 @@ 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
12
|
import { EggCore, ManifestStore, Router, utils } from "@eggjs/core";
|
|
13
13
|
import path from "node:path";
|
|
@@ -128,6 +128,7 @@ var EggApplicationCore = class extends EggCore {
|
|
|
128
128
|
this.dumpConfig();
|
|
129
129
|
this.dumpTiming();
|
|
130
130
|
this.dumpManifest();
|
|
131
|
+
ManifestStore.flushCompileCache();
|
|
131
132
|
this.coreLogger.info("[egg] dump config after ready, %sms", Date.now() - dumpStartTime);
|
|
132
133
|
}));
|
|
133
134
|
this.#setupTimeoutTimer();
|
|
@@ -141,6 +142,7 @@ var EggApplicationCore = class extends EggCore {
|
|
|
141
142
|
for (const clusterClient of this.#clusterClients) await close(clusterClient);
|
|
142
143
|
this.#clusterClients = [];
|
|
143
144
|
if (this.type === "application" && this.options.mode === "single") await this.agent?.close();
|
|
145
|
+
ManifestStore.flushCompileCache();
|
|
144
146
|
for (const logger of this.loggers.values()) logger.close();
|
|
145
147
|
this.messenger.close();
|
|
146
148
|
process.removeListener("unhandledRejection", this._unhandledRejectionHandler);
|
|
@@ -283,11 +285,18 @@ var EggApplicationCore = class extends EggCore {
|
|
|
283
285
|
}
|
|
284
286
|
/**
|
|
285
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
|
+
*
|
|
286
295
|
* @see https://github.com/node-modules/urllib
|
|
287
296
|
* @member {HttpClient}
|
|
288
297
|
*/
|
|
289
298
|
get httpClient() {
|
|
290
|
-
if (!this.#httpClient) this.#httpClient = this.createHttpClient();
|
|
299
|
+
if (!this.#httpClient) this.#httpClient = createTransparentProxy({ createReal: () => this.createHttpClient() });
|
|
291
300
|
return this.#httpClient;
|
|
292
301
|
}
|
|
293
302
|
/**
|
|
@@ -407,6 +416,7 @@ var EggApplicationCore = class extends EggCore {
|
|
|
407
416
|
if (this.loader.serverEnv === "local" && process.env.EGG_MANIFEST !== "true") return;
|
|
408
417
|
if (this.loader.manifest.data.generatedAt) return;
|
|
409
418
|
const manifest = this.loader.generateManifest();
|
|
419
|
+
ManifestStore.enableCompileCache(this.baseDir);
|
|
410
420
|
ManifestStore.write(this.baseDir, manifest).catch((err) => {
|
|
411
421
|
this.coreLogger.warn("[egg] dumpManifest write error: %s", err.message);
|
|
412
422
|
});
|
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 {}
|
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.9",
|
|
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/
|
|
104
|
-
"@eggjs/
|
|
105
|
-
"@eggjs/
|
|
106
|
-
"@eggjs/
|
|
107
|
-
"@eggjs/
|
|
108
|
-
"@eggjs/
|
|
109
|
-
"@eggjs/
|
|
110
|
-
"@eggjs/
|
|
111
|
-
"@eggjs/
|
|
112
|
-
"@eggjs/
|
|
113
|
-
"@eggjs/
|
|
114
|
-
"@eggjs/multipart": "5.0.2-beta.
|
|
115
|
-
"@eggjs/
|
|
116
|
-
"@eggjs/orm-plugin": "4.0.2-beta.
|
|
117
|
-
"@eggjs/
|
|
118
|
-
"@eggjs/
|
|
119
|
-
"@eggjs/security": "5.0.2-beta.
|
|
120
|
-
"@eggjs/
|
|
121
|
-
"@eggjs/schedule": "
|
|
122
|
-
"@eggjs/tegg
|
|
123
|
-
"@eggjs/
|
|
124
|
-
"@eggjs/
|
|
125
|
-
"@eggjs/
|
|
126
|
-
"@eggjs/
|
|
127
|
-
"@eggjs/
|
|
128
|
-
"@eggjs/
|
|
101
|
+
"@eggjs/ajv-plugin": "4.0.2-beta.9",
|
|
102
|
+
"@eggjs/controller-plugin": "4.0.2-beta.9",
|
|
103
|
+
"@eggjs/aop-plugin": "4.0.2-beta.9",
|
|
104
|
+
"@eggjs/cookies": "4.0.2-beta.9",
|
|
105
|
+
"@eggjs/cluster": "4.0.2-beta.9",
|
|
106
|
+
"@eggjs/core": "7.0.2-beta.9",
|
|
107
|
+
"@eggjs/dal-plugin": "4.0.2-beta.9",
|
|
108
|
+
"@eggjs/errors": "3.0.2-beta.9",
|
|
109
|
+
"@eggjs/eventbus-plugin": "4.0.2-beta.9",
|
|
110
|
+
"@eggjs/extend2": "5.0.2-beta.9",
|
|
111
|
+
"@eggjs/development": "5.0.2-beta.9",
|
|
112
|
+
"@eggjs/jsonp": "4.0.2-beta.9",
|
|
113
|
+
"@eggjs/i18n": "4.0.2-beta.9",
|
|
114
|
+
"@eggjs/multipart": "5.0.2-beta.9",
|
|
115
|
+
"@eggjs/logrotator": "5.0.2-beta.9",
|
|
116
|
+
"@eggjs/orm-plugin": "4.0.2-beta.9",
|
|
117
|
+
"@eggjs/schedule": "6.0.2-beta.9",
|
|
118
|
+
"@eggjs/onerror": "4.0.2-beta.9",
|
|
119
|
+
"@eggjs/security": "5.0.2-beta.9",
|
|
120
|
+
"@eggjs/session": "5.0.2-beta.9",
|
|
121
|
+
"@eggjs/schedule-plugin": "4.0.2-beta.9",
|
|
122
|
+
"@eggjs/tegg": "4.0.2-beta.9",
|
|
123
|
+
"@eggjs/tegg-plugin": "4.0.2-beta.9",
|
|
124
|
+
"@eggjs/static": "4.0.2-beta.9",
|
|
125
|
+
"@eggjs/utils": "5.0.2-beta.9",
|
|
126
|
+
"@eggjs/tegg-config": "4.0.2-beta.9",
|
|
127
|
+
"@eggjs/view": "4.0.2-beta.9",
|
|
128
|
+
"@eggjs/watcher": "5.0.2-beta.9"
|
|
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/mock": "7.0.2-beta.
|
|
146
|
-
"@eggjs/supertest": "9.0.2-beta.
|
|
147
|
-
"@eggjs/tracer": "4.0.2-beta.
|
|
144
|
+
"@eggjs/koa": "3.1.2-beta.9",
|
|
145
|
+
"@eggjs/mock": "7.0.2-beta.9",
|
|
146
|
+
"@eggjs/supertest": "9.0.2-beta.9",
|
|
147
|
+
"@eggjs/tracer": "4.0.2-beta.9"
|
|
148
148
|
},
|
|
149
149
|
"engines": {
|
|
150
150
|
"node": ">=22.18.0"
|