egg 4.1.0-beta.3 → 4.1.0-beta.30

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 (88) hide show
  1. package/dist/agent.d.ts +3 -7
  2. package/dist/agent.js +6 -10
  3. package/dist/app/extend/context.d.ts +166 -193
  4. package/dist/app/extend/context.js +259 -244
  5. package/dist/app/extend/helper.d.ts +31 -36
  6. package/dist/app/extend/helper.js +41 -45
  7. package/dist/app/extend/request.d.ts +127 -140
  8. package/dist/app/extend/request.js +258 -219
  9. package/dist/app/extend/response.d.ts +22 -32
  10. package/dist/app/extend/response.js +34 -36
  11. package/dist/app/middleware/body_parser.d.ts +2 -2
  12. package/dist/app/middleware/body_parser.js +3 -7
  13. package/dist/app/middleware/meta.d.ts +9 -10
  14. package/dist/app/middleware/meta.js +19 -13
  15. package/dist/app/middleware/notfound.d.ts +6 -10
  16. package/dist/app/middleware/notfound.js +28 -25
  17. package/dist/app/middleware/override_method.d.ts +2 -2
  18. package/dist/app/middleware/override_method.js +3 -7
  19. package/dist/app/middleware/site_file.d.ts +8 -12
  20. package/dist/app/middleware/site_file.js +52 -37
  21. package/dist/config/config.default.d.ts +3 -8
  22. package/dist/config/config.default.js +377 -256
  23. package/dist/config/config.local.d.ts +3 -10
  24. package/dist/config/config.local.js +7 -6
  25. package/dist/config/config.unittest.d.ts +3 -9
  26. package/dist/config/config.unittest.js +7 -9
  27. package/dist/config/favicon.png +0 -0
  28. package/dist/config/plugin.d.ts +3 -124
  29. package/dist/config/plugin.js +162 -53
  30. package/dist/index.d.ts +84 -19
  31. package/dist/index.js +87 -19
  32. package/dist/lib/agent.d.ts +12 -17
  33. package/dist/lib/agent.js +45 -54
  34. package/dist/lib/application.d.ts +47 -62
  35. package/dist/lib/application.js +249 -197
  36. package/dist/lib/core/base_context_class.d.ts +13 -17
  37. package/dist/lib/core/base_context_class.js +15 -17
  38. package/dist/lib/core/base_context_logger.d.ts +35 -39
  39. package/dist/lib/core/base_context_logger.js +60 -58
  40. package/dist/lib/core/base_hook_class.d.ts +11 -17
  41. package/dist/lib/core/base_hook_class.js +22 -26
  42. package/dist/lib/core/context_httpclient.d.ts +16 -20
  43. package/dist/lib/core/context_httpclient.js +26 -29
  44. package/dist/lib/core/httpclient.d.ts +12 -15
  45. package/dist/lib/core/httpclient.js +37 -34
  46. package/dist/lib/core/logger.d.ts +3 -7
  47. package/dist/lib/core/logger.js +36 -30
  48. package/dist/lib/core/messenger/IMessenger.d.ts +49 -53
  49. package/dist/lib/core/messenger/IMessenger.js +2 -1
  50. package/dist/lib/core/messenger/base.d.ts +7 -11
  51. package/dist/lib/core/messenger/base.js +29 -29
  52. package/dist/lib/core/messenger/index.d.ts +4 -8
  53. package/dist/lib/core/messenger/index.js +8 -11
  54. package/dist/lib/core/messenger/ipc.d.ts +55 -59
  55. package/dist/lib/core/messenger/ipc.js +138 -120
  56. package/dist/lib/core/messenger/local.d.ts +56 -61
  57. package/dist/lib/core/messenger/local.js +131 -124
  58. package/dist/lib/core/utils.d.ts +2 -5
  59. package/dist/lib/core/utils.js +66 -44
  60. package/dist/lib/egg.d.ts +272 -294
  61. package/dist/lib/egg.js +574 -507
  62. package/dist/lib/error/CookieLimitExceedError.d.ts +4 -7
  63. package/dist/lib/error/CookieLimitExceedError.js +12 -15
  64. package/dist/lib/error/MessageUnhandledRejectionError.d.ts +4 -7
  65. package/dist/lib/error/MessageUnhandledRejectionError.js +12 -15
  66. package/dist/lib/error/index.d.ts +2 -3
  67. package/dist/lib/error/index.js +3 -4
  68. package/dist/lib/loader/AgentWorkerLoader.d.ts +7 -12
  69. package/dist/lib/loader/AgentWorkerLoader.js +18 -22
  70. package/dist/lib/loader/AppWorkerLoader.d.ts +12 -17
  71. package/dist/lib/loader/AppWorkerLoader.js +37 -35
  72. package/dist/lib/loader/EggApplicationLoader.d.ts +3 -7
  73. package/dist/lib/loader/EggApplicationLoader.js +4 -7
  74. package/dist/lib/loader/index.d.ts +3 -4
  75. package/dist/lib/loader/index.js +4 -5
  76. package/dist/lib/start.d.ts +18 -22
  77. package/dist/lib/start.js +42 -32
  78. package/dist/lib/types.d.ts +309 -230
  79. package/dist/lib/types.js +31 -14
  80. package/dist/lib/types.plugin.d.ts +21 -0
  81. package/dist/lib/types.plugin.js +24 -0
  82. package/dist/schedule.d.ts +2 -0
  83. package/dist/schedule.js +5 -0
  84. package/dist/urllib.d.ts +1 -1
  85. package/dist/urllib.js +2 -3
  86. package/package.json +42 -32
  87. package/dist/lib/utils.d.ts +0 -5
  88. package/dist/lib/utils.js +0 -14
package/dist/lib/egg.d.ts CHANGED
@@ -1,306 +1,284 @@
1
- import { EggApplicationLoader } from "./loader/EggApplicationLoader.js";
2
- import { Agent } from "./agent.js";
3
- import { Application } from "./application.js";
4
- import { EggContextHttpClient as HttpClient, HttpClientOptions, HttpClientRequestOptions, HttpClientRequestURL, HttpClientResponse } from "./core/httpclient.js";
5
- import Context from "../app/extend/context.js";
6
- import { EggAppConfig as EggAppConfig$1 } from "./types.js";
7
- import { IMessenger } from "./core/messenger/IMessenger.js";
8
- import { ContextHttpClient } from "./core/context_httpclient.js";
9
- import { BaseContextClass as BaseContextClass$1 } from "./core/base_context_class.js";
10
- import { BaseHookClass } from "./core/base_hook_class.js";
11
- import { EggCore, EggCoreOptions, ILifecycleBoot, MiddlewareFunc as MiddlewareFunc$1, Next, Request as Request$1, Response as Response$1, Router } from "@eggjs/core";
12
- import { IncomingMessage, ServerResponse } from "node:http";
13
- import { AsyncLocalStorage } from "node:async_hooks";
14
- import { EggContextLogger, EggLogger, EggLoggers } from "egg-logger";
15
- import { Cookies } from "@eggjs/cookies";
16
-
17
- //#region src/lib/egg.d.ts
18
- declare const EGG_PATH: unique symbol;
19
- interface EggApplicationCoreOptions extends Omit<EggCoreOptions, 'baseDir'> {
20
- mode?: 'cluster' | 'single';
21
- clusterPort?: number;
22
- baseDir?: string;
1
+ import { type IncomingMessage, type ServerResponse } from 'node:http';
2
+ import type { AsyncLocalStorage } from 'node:async_hooks';
3
+ import { EggCore, Router } from '@eggjs/core';
4
+ import type { EggCoreOptions, Next, MiddlewareFunc as EggCoreMiddlewareFunc, ILifecycleBoot } from '@eggjs/core';
5
+ import { EggContextLogger as ContextLogger, EggLoggers, EggLogger } from 'egg-logger';
6
+ import { Cookies as ContextCookies } from '@eggjs/cookies';
7
+ import type { Agent } from './agent.ts';
8
+ import type { Application } from './application.ts';
9
+ import Context from '../app/extend/context.ts';
10
+ import Request from '../app/extend/request.ts';
11
+ import Response from '../app/extend/response.ts';
12
+ import type { EggAppConfig } from './types.ts';
13
+ import { type IMessenger } from './core/messenger/index.ts';
14
+ import { ContextHttpClient } from './core/context_httpclient.ts';
15
+ import { HttpClient, type HttpClientRequestOptions, type HttpClientRequestURL, type HttpClientResponse, type HttpClientOptions } from './core/httpclient.ts';
16
+ import { BaseContextClass } from './core/base_context_class.ts';
17
+ import { BaseHookClass } from './core/base_hook_class.ts';
18
+ import type { EggApplicationLoader } from './loader/index.ts';
19
+ export interface EggApplicationCoreOptions extends Omit<EggCoreOptions, 'baseDir'> {
20
+ mode?: 'cluster' | 'single';
21
+ clusterPort?: number;
22
+ baseDir?: string;
23
23
  }
24
- declare class Request extends Request$1 {
25
- app: EggCore;
26
- response: Response;
27
- ctx: Context;
28
- }
29
- declare class Response extends Response$1 {
30
- app: EggCore;
31
- request: Request;
32
- ctx: Context;
33
- }
34
- type EggContext = Context;
35
- type MiddlewareFunc<T extends Context = Context> = MiddlewareFunc$1<T>;
24
+ export { Request, Response };
25
+ export type { ILifecycleBoot, ILifecycleBoot as IBoot, Next, };
26
+ export type EggContext = Context;
27
+ export type MiddlewareFunc<T extends Context = Context> = EggCoreMiddlewareFunc<T>;
28
+ export { Context, Router };
36
29
  /**
37
30
  * Based on koa's Application
38
31
  * @see https://github.com/eggjs/egg-core
39
32
  * @see https://github.com/eggjs/koa/blob/master/src/application.ts
40
33
  * @augments EggCore
41
34
  */
42
- declare class EggApplicationCore extends EggCore {
43
- #private;
44
- ctxStorage: AsyncLocalStorage<Context>;
45
- ContextCookies: typeof Cookies;
46
- ContextLogger: typeof EggContextLogger;
47
- ContextHttpClient: typeof ContextHttpClient;
48
- HttpClient: typeof HttpClient;
49
- HttpClientNext: typeof HttpClient;
50
- /**
51
- * Retrieve base context class
52
- * @member {BaseContextClass} BaseContextClass
53
- * @since 1.0.0
54
- */
55
- BaseContextClass: typeof BaseContextClass$1;
56
- /**
57
- * Retrieve base controller
58
- * @member {Controller} Controller
59
- * @since 1.0.0
60
- */
61
- Controller: typeof BaseContextClass$1;
62
- /**
63
- * Retrieve base service
64
- * @member {Service} Service
65
- * @since 1.0.0
66
- */
67
- Service: typeof BaseContextClass$1;
68
- /**
69
- * Retrieve base subscription
70
- * @member {Subscription} Subscription
71
- * @since 2.12.0
72
- */
73
- Subscription: typeof BaseContextClass$1;
74
- /**
75
- * Retrieve base context class
76
- * @member {BaseHookClass} BaseHookClass
77
- */
78
- BaseHookClass: typeof BaseHookClass;
79
- /**
80
- * Retrieve base boot
81
- * @member {Boot}
82
- * @alias BaseHookClass
83
- */
84
- Boot: typeof BaseHookClass;
85
- options: Required<EggApplicationCoreOptions>;
86
- readonly messenger: IMessenger;
87
- agent?: Agent;
88
- application?: Application;
89
- loader: EggApplicationLoader;
90
- /**
91
- * @class
92
- * @param {Object} options
93
- * - {Object} [type] - type of instance, Agent and Application both extend koa, type can determine what it is.
94
- * - {String} [baseDir] - app root dir, default is `process.cwd()`
95
- * - {Object} [plugins] - custom plugin config, use it in unittest
96
- * - {String} [mode] - process mode, can be cluster / single, default is `cluster`
97
- */
98
- constructor(options?: EggApplicationCoreOptions);
99
- /**
100
- * @deprecated please use `options` property instead
101
- */
102
- get _options(): Required<EggApplicationCoreOptions>;
103
- protected loadConfig(): Promise<void>;
104
- protected load(): Promise<void>;
105
- /**
106
- * Usage: new ApiClient({ cluster: app.cluster })
107
- */
108
- get cluster(): (clientClass: unknown, options?: object) => any;
109
- /**
110
- * Wrap the Client with Leader/Follower Pattern
111
- *
112
- * @description almost the same as Agent.cluster API, the only different is that this method create Follower.
113
- *
114
- * @see https://github.com/node-modules/cluster-client
115
- * @param {Function} clientClass - client class function
116
- * @param {Object} [options]
117
- * - {Boolean} [autoGenerate] - whether generate delegate rule automatically, default is true
118
- * - {Function} [formatKey] - a method to transform the subscription info into a string,default is JSON.stringify
119
- * - {Object} [transcode|JSON.stringify/parse]
120
- * - {Function} encode - custom serialize method
121
- * - {Function} decode - custom deserialize method
122
- * - {Boolean} [isBroadcast] - whether broadcast subscription result to all followers or just one, default is true
123
- * - {Number} [responseTimeout] - response timeout, default is 3 seconds
124
- * - {Number} [maxWaitTime|30000] - leader startup max time, default is 30 seconds
125
- * @return {ClientWrapper} wrapper
126
- */
127
- clusterWrapper(clientClass: unknown, options?: object): any;
128
- /**
129
- * print the information when console.log(app)
130
- * @return {Object} inspected app.
131
- * @since 1.0.0
132
- * @example
133
- * ```js
134
- * console.log(app);
135
- * =>
136
- * {
137
- * name: 'mock-app',
138
- * env: 'test',
139
- * subdomainOffset: 2,
140
- * config: '<egg config>',
141
- * controller: '<egg controller>',
142
- * service: '<egg service>',
143
- * middlewares: '<egg middlewares>',
144
- * urllib: '<egg urllib>',
145
- * loggers: '<egg loggers>'
146
- * }
147
- * ```
148
- */
149
- inspect(): any;
150
- toJSON(): any;
151
- /**
152
- * http request helper base on {@link httpclient}, it will auto save httpclient log.
153
- * Keep the same api with `httpclient.request(url, args)`.
154
- *
155
- * See https://github.com/node-modules/urllib#api-doc for more details.
156
- *
157
- * @param {String} url request url address.
158
- * @param {Object} options
159
- * - method {String} - Request method, defaults to GET. Could be GET, POST, DELETE or PUT. Alias 'type'.
160
- * - data {Object} - Data to be sent. Will be stringify automatically.
161
- * - dataType {String} - String - Type of response data. Could be `text` or `json`.
162
- * If it's `text`, the callback data would be a String.
163
- * If it's `json`, the data of callback would be a parsed JSON Object.
164
- * Default callback data would be a Buffer.
165
- * - headers {Object} - Request headers.
166
- * - timeout {Number} - Request timeout in milliseconds. Defaults to exports.TIMEOUT.
167
- * Include remote server connecting timeout and response timeout.
168
- * When timeout happen, will return ConnectionTimeout or ResponseTimeout.
169
- * - auth {String} - `username:password` used in HTTP Basic Authorization.
170
- * - followRedirect {Boolean} - follow HTTP 3xx responses as redirects. defaults to false.
171
- * - gzip {Boolean} - let you get the res object when request connected, default false. alias customResponse
172
- * - nestedQuerystring {Boolean} - urllib default use querystring to stringify form data which don't
173
- * support nested object, will use qs instead of querystring to support nested object by set this option to true.
174
- * - more options see https://github.com/node-modules/urllib
175
- * @return {Object}
176
- * - status {Number} - HTTP response status
177
- * - headers {Object} - HTTP response headers
178
- * - res {Object} - HTTP response meta
179
- * - data {Object} - HTTP response body
180
- *
181
- * @example
182
- * ```js
183
- * const result = await app.curl('http://example.com/foo.json', {
184
- * method: 'GET',
185
- * dataType: 'json',
186
- * });
187
- * console.log(result.status, result.headers, result.data);
188
- * ```
189
- */
190
- curl<T = any>(url: HttpClientRequestURL, options?: HttpClientRequestOptions): Promise<HttpClientResponse<T>>;
191
- /**
192
- * Create a new HttpClient instance with custom options
193
- * @param {Object} [options] HttpClient init options
194
- */
195
- createHttpClient(options?: HttpClientOptions): HttpClient;
196
- /**
197
- * HttpClient instance
198
- * @see https://github.com/node-modules/urllib
199
- * @member {HttpClient}
200
- */
201
- get httpClient(): HttpClient;
202
- /**
203
- * @deprecated please use httpClient instead
204
- * @alias httpClient
205
- * @member {HttpClient}
206
- */
207
- get httpclient(): HttpClient;
208
- /**
209
- * All loggers contain logger, coreLogger and customLogger
210
- * @member {Object}
211
- * @since 1.0.0
212
- */
213
- get loggers(): EggLoggers;
214
- /**
215
- * Get logger by name, it's equal to app.loggers['name'],
216
- * but you can extend it with your own logical.
217
- * @param {String} name - logger name
218
- * @return {Logger} logger
219
- */
220
- getLogger(name: string): EggLogger;
221
- /**
222
- * application logger, log file is `$HOME/logs/{appname}/{appname}-web`
223
- * @member {Logger}
224
- * @since 1.0.0
225
- */
226
- get logger(): EggLogger;
227
- /**
228
- * core logger for framework and plugins, log file is `$HOME/logs/{appname}/egg-web`
229
- * @member {Logger}
230
- * @since 1.0.0
231
- */
232
- get coreLogger(): EggLogger;
233
- _unhandledRejectionHandler(err: any): void;
234
- /**
235
- * dump out the config and meta object
236
- * @private
237
- */
238
- dumpConfigToObject(): {
239
- config: Record<string, any>;
240
- meta: Record<string, any>;
241
- };
242
- /**
243
- * save app.config to `run/${type}_config.json`
244
- * @private
245
- */
246
- dumpConfig(): void;
247
- dumpTiming(): void;
248
- get [EGG_PATH](): string;
249
- get config(): EggAppConfig$1;
250
- /**
251
- * app.env delegate app.config.env
252
- * @deprecated
253
- */
254
- get env(): string;
255
- set env(_: string);
256
- /**
257
- * app.proxy delegate app.config.proxy
258
- * @deprecated
259
- */
260
- get proxy(): boolean;
261
- set proxy(_: boolean);
262
- /**
263
- * Create an anonymous context, the context isn't request level, so the request is mocked.
264
- * then you can use context level API like `ctx.service`
265
- * @member {String} EggApplication#createAnonymousContext
266
- * @param {Request} [req] - if you want to mock request like querystring, you can pass an object to this function.
267
- * @return {Context} context
268
- */
269
- createAnonymousContext(req?: any): EggContext;
270
- /**
271
- * Run async function in the anonymous context scope
272
- * @see Context#runInAnonymousContextScope
273
- * @param {Function} scope - the first args is an anonymous ctx, scope should be async function
274
- * @param {Request} [req] - if you want to mock request like querystring, you can pass an object to this function.
275
- */
276
- runInAnonymousContextScope(scope: (ctx: Context) => Promise<void>, req?: unknown): Promise<void>;
277
- /**
278
- * Create egg context
279
- * @function EggApplication#createContext
280
- * @param {Req} req - node native Request object
281
- * @param {Res} res - node native Response object
282
- * @return {Context} context object
283
- */
284
- createContext(req: IncomingMessage, res: ServerResponse): Context;
285
- }
286
- declare module '@eggjs/core' {
287
- interface EggCore {
35
+ export declare class EggApplicationCore extends EggCore {
36
+ #private;
37
+ ctxStorage: AsyncLocalStorage<Context>;
38
+ /**
39
+ * Get the current request context from AsyncLocalStorage.
40
+ * This provides access to the context object for the current request lifecycle.
41
+ * @returns {Context | undefined} The current request context, or undefined if not in a request scope.
42
+ */
43
+ get currentContext(): Context | undefined;
44
+ ContextCookies: typeof ContextCookies;
45
+ ContextLogger: typeof ContextLogger;
46
+ ContextHttpClient: typeof ContextHttpClient;
47
+ HttpClient: typeof HttpClient;
48
+ HttpClientNext: typeof HttpClient;
49
+ /**
50
+ * Retrieve base context class
51
+ * @member {BaseContextClass} BaseContextClass
52
+ * @since 1.0.0
53
+ */
54
+ BaseContextClass: typeof BaseContextClass;
55
+ /**
56
+ * Retrieve base controller
57
+ * @member {Controller} Controller
58
+ * @since 1.0.0
59
+ */
60
+ Controller: typeof BaseContextClass;
61
+ /**
62
+ * Retrieve base service
63
+ * @member {Service} Service
64
+ * @since 1.0.0
65
+ */
66
+ Service: typeof BaseContextClass;
67
+ /**
68
+ * Retrieve base subscription
69
+ * @member {Subscription} Subscription
70
+ * @since 2.12.0
71
+ */
72
+ Subscription: typeof BaseContextClass;
73
+ /**
74
+ * Retrieve base context class
75
+ * @member {BaseHookClass} BaseHookClass
76
+ */
77
+ BaseHookClass: typeof BaseHookClass;
78
+ /**
79
+ * Retrieve base boot
80
+ * @member {Boot}
81
+ * @alias BaseHookClass
82
+ */
83
+ Boot: typeof BaseHookClass;
84
+ options: Required<EggApplicationCoreOptions>;
85
+ readonly messenger: IMessenger;
86
+ agent?: Agent;
87
+ application?: Application;
88
+ loader: EggApplicationLoader;
89
+ /**
90
+ * @class
91
+ * @param {Object} options
92
+ * - {Object} [type] - type of instance, Agent and Application both extend koa, type can determine what it is.
93
+ * - {String} [baseDir] - app root dir, default is `process.cwd()`
94
+ * - {Object} [plugins] - custom plugin config, use it in unittest
95
+ * - {String} [mode] - process mode, can be cluster / single, default is `cluster`
96
+ */
97
+ constructor(options?: EggApplicationCoreOptions);
98
+ /**
99
+ * @deprecated please use `options` property instead
100
+ */
101
+ get _options(): Required<EggApplicationCoreOptions>;
102
+ protected loadConfig(): Promise<void>;
103
+ protected load(): Promise<void>;
104
+ /**
105
+ * Usage: new ApiClient({ cluster: app.cluster })
106
+ */
107
+ get cluster(): (clientClass: unknown, options?: object) => any;
108
+ /**
109
+ * Wrap the Client with Leader/Follower Pattern
110
+ *
111
+ * @description almost the same as Agent.cluster API, the only different is that this method create Follower.
112
+ *
113
+ * @see https://github.com/node-modules/cluster-client
114
+ * @param {Function} clientClass - client class function
115
+ * @param {Object} [options]
116
+ * - {Boolean} [autoGenerate] - whether generate delegate rule automatically, default is true
117
+ * - {Function} [formatKey] - a method to transform the subscription info into a string,default is JSON.stringify
118
+ * - {Object} [transcode|JSON.stringify/parse]
119
+ * - {Function} encode - custom serialize method
120
+ * - {Function} decode - custom deserialize method
121
+ * - {Boolean} [isBroadcast] - whether broadcast subscription result to all followers or just one, default is true
122
+ * - {Number} [responseTimeout] - response timeout, default is 3 seconds
123
+ * - {Number} [maxWaitTime|30000] - leader startup max time, default is 30 seconds
124
+ * @return {ClientWrapper} wrapper
125
+ */
126
+ clusterWrapper(clientClass: unknown, options?: object): any;
127
+ /**
128
+ * print the information when console.log(app)
129
+ * @return {Object} inspected app.
130
+ * @since 1.0.0
131
+ * @example
132
+ * ```js
133
+ * console.log(app);
134
+ * =>
135
+ * {
136
+ * name: 'mock-app',
137
+ * env: 'test',
138
+ * subdomainOffset: 2,
139
+ * config: '<egg config>',
140
+ * controller: '<egg controller>',
141
+ * service: '<egg service>',
142
+ * middlewares: '<egg middlewares>',
143
+ * urllib: '<egg urllib>',
144
+ * loggers: '<egg loggers>'
145
+ * }
146
+ * ```
147
+ */
288
148
  inspect(): any;
289
- get currentContext(): EggContext | undefined;
290
- ctxStorage: AsyncLocalStorage<EggContext>;
291
- getLogger(name: string): EggLogger;
292
- get loggers(): EggLoggers;
149
+ toJSON(): any;
150
+ /**
151
+ * http request helper base on {@link httpclient}, it will auto save httpclient log.
152
+ * Keep the same api with `httpclient.request(url, args)`.
153
+ *
154
+ * See https://github.com/node-modules/urllib#api-doc for more details.
155
+ *
156
+ * @param {String} url request url address.
157
+ * @param {Object} options
158
+ * - method {String} - Request method, defaults to GET. Could be GET, POST, DELETE or PUT. Alias 'type'.
159
+ * - data {Object} - Data to be sent. Will be stringify automatically.
160
+ * - dataType {String} - String - Type of response data. Could be `text` or `json`.
161
+ * If it's `text`, the callback data would be a String.
162
+ * If it's `json`, the data of callback would be a parsed JSON Object.
163
+ * Default callback data would be a Buffer.
164
+ * - headers {Object} - Request headers.
165
+ * - timeout {Number} - Request timeout in milliseconds. Defaults to exports.TIMEOUT.
166
+ * Include remote server connecting timeout and response timeout.
167
+ * When timeout happen, will return ConnectionTimeout or ResponseTimeout.
168
+ * - auth {String} - `username:password` used in HTTP Basic Authorization.
169
+ * - followRedirect {Boolean} - follow HTTP 3xx responses as redirects. defaults to false.
170
+ * - gzip {Boolean} - let you get the res object when request connected, default false. alias customResponse
171
+ * - nestedQuerystring {Boolean} - urllib default use querystring to stringify form data which don't
172
+ * support nested object, will use qs instead of querystring to support nested object by set this option to true.
173
+ * - more options see https://github.com/node-modules/urllib
174
+ * @return {Object}
175
+ * - status {Number} - HTTP response status
176
+ * - headers {Object} - HTTP response headers
177
+ * - res {Object} - HTTP response meta
178
+ * - data {Object} - HTTP response body
179
+ *
180
+ * @example
181
+ * ```js
182
+ * const result = await app.curl('http://example.com/foo.json', {
183
+ * method: 'GET',
184
+ * dataType: 'json',
185
+ * });
186
+ * console.log(result.status, result.headers, result.data);
187
+ * ```
188
+ */
189
+ curl<T = any>(url: HttpClientRequestURL, options?: HttpClientRequestOptions): Promise<HttpClientResponse<T>>;
190
+ /**
191
+ * Create a new HttpClient instance with custom options
192
+ * @param {Object} [options] HttpClient init options
193
+ */
293
194
  createHttpClient(options?: HttpClientOptions): HttpClient;
294
- HttpClient: typeof HttpClient;
195
+ /**
196
+ * HttpClient instance
197
+ * @see https://github.com/node-modules/urllib
198
+ * @member {HttpClient}
199
+ */
295
200
  get httpClient(): HttpClient;
296
- curl<T = any>(url: HttpClientRequestURL, options?: HttpClientRequestOptions): Promise<HttpClientResponse<T>>;
201
+ /**
202
+ * @deprecated please use httpClient instead
203
+ * @alias httpClient
204
+ * @member {HttpClient}
205
+ */
206
+ get httpclient(): HttpClient;
207
+ /**
208
+ * All loggers contain logger, coreLogger and customLogger
209
+ * @member {Object}
210
+ * @since 1.0.0
211
+ */
212
+ get loggers(): EggLoggers;
213
+ /**
214
+ * Get logger by name, it's equal to app.loggers['name'],
215
+ * but you can extend it with your own logical.
216
+ * @param {String} name - logger name
217
+ * @return {Logger} logger
218
+ */
219
+ getLogger(name: string): EggLogger;
220
+ /**
221
+ * application logger, log file is `$HOME/logs/{appname}/{appname}-web`
222
+ * @member {Logger}
223
+ * @since 1.0.0
224
+ */
225
+ get logger(): EggLogger;
226
+ /**
227
+ * core logger for framework and plugins, log file is `$HOME/logs/{appname}/egg-web`
228
+ * @member {Logger}
229
+ * @since 1.0.0
230
+ */
231
+ get coreLogger(): EggLogger;
232
+ _unhandledRejectionHandler(err: any): void;
233
+ /**
234
+ * dump out the config and meta object
235
+ * @private
236
+ */
237
+ dumpConfigToObject(): {
238
+ config: any;
239
+ meta: any;
240
+ };
241
+ /**
242
+ * save app.config to `run/${type}_config.json`
243
+ * @private
244
+ */
245
+ dumpConfig(): void;
246
+ dumpTiming(): void;
247
+ protected customEggPaths(): string[];
248
+ get config(): EggAppConfig;
249
+ /**
250
+ * app.env delegate app.config.env
251
+ * @deprecated
252
+ */
253
+ get env(): string;
254
+ set env(_: any);
255
+ /**
256
+ * app.proxy delegate app.config.proxy
257
+ * @deprecated
258
+ */
259
+ get proxy(): boolean;
260
+ set proxy(_: any);
261
+ /**
262
+ * Create an anonymous context, the context isn't request level, so the request is mocked.
263
+ * then you can use context level API like `ctx.service`
264
+ * @member {String} EggApplication#createAnonymousContext
265
+ * @param {Request} [req] - if you want to mock request like querystring, you can pass an object to this function.
266
+ * @return {Context} context
267
+ */
297
268
  createAnonymousContext(req?: any): EggContext;
298
- runInAnonymousContextScope(scope: (ctx: Context) => Promise<void>, req?: unknown): Promise<void>;
299
- readonly messenger: IMessenger;
300
- Subscription: typeof BaseContextClass$1;
301
- BaseHookClass: typeof BaseHookClass;
302
- Boot: typeof BaseHookClass;
303
- }
269
+ /**
270
+ * Run async function in the anonymous context scope
271
+ * @see Context#runInAnonymousContextScope
272
+ * @param {Function} scope - the first args is an anonymous ctx, scope should be async function
273
+ * @param {Request} [req] - if you want to mock request like querystring, you can pass an object to this function.
274
+ */
275
+ runInAnonymousContextScope<T = void>(scope: (ctx: Context) => Promise<T>, req?: unknown): Promise<T>;
276
+ /**
277
+ * Create egg context
278
+ * @function EggApplication#createContext
279
+ * @param {Req} req - node native Request object
280
+ * @param {Res} res - node native Response object
281
+ * @return {Context} context object
282
+ */
283
+ createContext(req: IncomingMessage, res: ServerResponse): Context;
304
284
  }
305
- //#endregion
306
- export { Context, EggApplicationCore, EggApplicationCoreOptions, EggContext, type ILifecycleBoot as IBoot, type ILifecycleBoot, MiddlewareFunc, type Next, Request, Response, Router };