egg 4.1.0-beta.20 → 4.1.0-beta.22

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 (123) hide show
  1. package/dist/agent.d.ts +3 -17
  2. package/dist/agent.js +7 -11
  3. package/dist/app/extend/context.d.ts +180 -12
  4. package/dist/app/extend/context.js +259 -3
  5. package/dist/app/extend/helper.d.ts +37 -12
  6. package/dist/app/extend/helper.js +43 -5
  7. package/dist/app/extend/request.d.ts +132 -12
  8. package/dist/app/extend/request.js +265 -4
  9. package/dist/app/extend/response.d.ts +25 -2
  10. package/dist/app/extend/response.js +34 -3
  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 +10 -12
  14. package/dist/app/middleware/meta.js +19 -13
  15. package/dist/app/middleware/notfound.d.ts +7 -12
  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 +9 -12
  20. package/dist/app/middleware/site_file.js +52 -37
  21. package/dist/config/config.default.d.ts +2 -16
  22. package/dist/config/config.default.js +375 -282
  23. package/dist/config/config.local.d.ts +5 -7
  24. package/dist/config/config.local.js +9 -6
  25. package/dist/config/config.unittest.d.ts +5 -7
  26. package/dist/config/config.unittest.js +8 -9
  27. package/dist/config/plugin.d.ts +120 -122
  28. package/dist/config/plugin.js +121 -53
  29. package/dist/index.d.ts +66 -13
  30. package/dist/index.js +70 -30
  31. package/dist/lib/agent.d.ts +19 -12
  32. package/dist/lib/agent.js +48 -22
  33. package/dist/lib/application.d.ts +56 -12
  34. package/dist/lib/application.js +261 -23
  35. package/dist/lib/core/base_context_class.d.ts +18 -12
  36. package/dist/lib/core/base_context_class.js +17 -4
  37. package/dist/lib/core/base_context_logger.d.ts +36 -12
  38. package/dist/lib/core/base_context_logger.js +60 -3
  39. package/dist/lib/core/base_hook_class.d.ts +11 -12
  40. package/dist/lib/core/base_hook_class.js +22 -3
  41. package/dist/lib/core/context_httpclient.d.ts +17 -12
  42. package/dist/lib/core/context_httpclient.js +26 -3
  43. package/dist/lib/core/httpclient.d.ts +14 -12
  44. package/dist/lib/core/httpclient.js +39 -3
  45. package/dist/lib/core/logger.d.ts +3 -17
  46. package/dist/lib/core/logger.js +37 -3
  47. package/dist/lib/core/messenger/IMessenger.d.ts +50 -2
  48. package/dist/lib/core/messenger/IMessenger.js +2 -1
  49. package/dist/lib/core/messenger/base.d.ts +8 -13
  50. package/dist/lib/core/messenger/base.js +28 -17
  51. package/dist/lib/core/messenger/index.d.ts +7 -12
  52. package/dist/lib/core/messenger/index.js +10 -17
  53. package/dist/lib/core/messenger/ipc.d.ts +55 -68
  54. package/dist/lib/core/messenger/ipc.js +151 -17
  55. package/dist/lib/core/messenger/local.d.ts +56 -69
  56. package/dist/lib/core/messenger/local.js +128 -17
  57. package/dist/lib/core/utils.d.ts +2 -5
  58. package/dist/lib/core/utils.js +70 -3
  59. package/dist/lib/egg.d.ts +285 -12
  60. package/dist/lib/egg.js +581 -17
  61. package/dist/lib/error/CookieLimitExceedError.d.ts +5 -2
  62. package/dist/lib/error/CookieLimitExceedError.js +12 -3
  63. package/dist/lib/error/MessageUnhandledRejectionError.d.ts +5 -2
  64. package/dist/lib/error/MessageUnhandledRejectionError.js +12 -3
  65. package/dist/lib/error/index.d.ts +2 -4
  66. package/dist/lib/error/index.js +3 -5
  67. package/dist/lib/loader/AgentWorkerLoader.d.ts +12 -3
  68. package/dist/lib/loader/AgentWorkerLoader.js +20 -4
  69. package/dist/lib/loader/AppWorkerLoader.d.ts +17 -3
  70. package/dist/lib/loader/AppWorkerLoader.js +39 -4
  71. package/dist/lib/loader/EggApplicationLoader.d.ts +4 -2
  72. package/dist/lib/loader/EggApplicationLoader.js +4 -3
  73. package/dist/lib/loader/index.d.ts +3 -5
  74. package/dist/lib/loader/index.js +4 -6
  75. package/dist/lib/start.d.ts +24 -12
  76. package/dist/lib/start.js +46 -27
  77. package/dist/lib/types.d.ts +281 -12
  78. package/dist/lib/types.js +31 -4
  79. package/dist/lib/types.plugin.d.ts +12 -1
  80. package/dist/lib/types.plugin.js +14 -3
  81. package/dist/lib/utils.d.ts +2 -5
  82. package/dist/lib/utils.js +14 -3
  83. package/dist/urllib.d.ts +1 -1
  84. package/dist/urllib.js +2 -3
  85. package/package.json +23 -23
  86. package/dist/AgentWorkerLoader-DG_hAClt.d.ts +0 -17
  87. package/dist/AgentWorkerLoader-D_hceBRW.js +0 -24
  88. package/dist/AppWorkerLoader-CAtxJvGl.js +0 -37
  89. package/dist/AppWorkerLoader-CT875rYM.d.ts +0 -22
  90. package/dist/CookieLimitExceedError-CAW0HYJw.d.ts +0 -8
  91. package/dist/CookieLimitExceedError-DLGakbeu.js +0 -15
  92. package/dist/EggApplicationLoader-CMe1VQt1.js +0 -7
  93. package/dist/EggApplicationLoader-PnIvd5oV.d.ts +0 -8
  94. package/dist/IMessenger-C9g6ypSI.d.ts +0 -54
  95. package/dist/MessageUnhandledRejectionError-Lq5fWw24.d.ts +0 -8
  96. package/dist/MessageUnhandledRejectionError-oD_E1Ewl.js +0 -15
  97. package/dist/agent-BfFWeJj4.js +0 -55
  98. package/dist/application-DVwFQSa9.js +0 -208
  99. package/dist/base-KLVtlzUD.d.ts +0 -12
  100. package/dist/base_context_class-Xc1OZql9.js +0 -19
  101. package/dist/base_context_logger-CZU59PGA.js +0 -58
  102. package/dist/base_hook_class-D0Gu2p8r.js +0 -26
  103. package/dist/base_hook_class-R8A8gm1s.d.ts +0 -1109
  104. package/dist/context-D1Wg7CXs.js +0 -244
  105. package/dist/context_httpclient-BpRMdJhf.js +0 -29
  106. package/dist/egg-DVo5e_lr.js +0 -800
  107. package/dist/error-BYo_LRnd.js +0 -1
  108. package/dist/helper-B3PKMPXq.js +0 -47
  109. package/dist/httpclient-C1QPc_R7.js +0 -36
  110. package/dist/index-CUPkUUOR.d.ts +0 -1
  111. package/dist/index-CkgLZdB4.d.ts +0 -1
  112. package/dist/loader-3myZ-rpm.js +0 -1
  113. package/dist/logger-C4tIcO3S.js +0 -31
  114. package/dist/request-Cy_1DlaX.js +0 -225
  115. package/dist/response-CDeQ9Sx2.js +0 -36
  116. package/dist/response-DlNYDj00.d.ts +0 -29
  117. package/dist/src-BuOjXSrB.js +0 -3
  118. package/dist/start-4E84z796.js +0 -35
  119. package/dist/types-dKSyDnVp.js +0 -32
  120. package/dist/types.plugin-B2v0K0I8.js +0 -14
  121. package/dist/types.plugin-C3D5I7VD.d.ts +0 -12
  122. package/dist/utils-B1Rjsoi9.js +0 -48
  123. package/dist/utils-BDoYg6z6.js +0 -14
@@ -1 +0,0 @@
1
- export { };
@@ -1,47 +0,0 @@
1
- import { BaseContextClass } from "./base_context_class-Xc1OZql9.js";
2
- import url from "node:url";
3
-
4
- //#region src/app/extend/helper.ts
5
- /**
6
- * The Helper class which can be used as utility function.
7
- * We support developers to extend Helper through ${baseDir}/app/extend/helper.js ,
8
- * then you can use all method on `ctx.helper` that is a instance of Helper.
9
- */
10
- var Helper = class extends BaseContextClass {
11
- /**
12
- * Generate URL path(without host) for route. Takes the route name and a map of named params.
13
- * @function Helper#pathFor
14
- * @param {String} name - Router Name
15
- * @param {Object} params - Other params
16
- *
17
- * @example
18
- * ```js
19
- * app.get('home', '/index.htm', 'home.index');
20
- * ctx.helper.pathFor('home', { by: 'recent', limit: 20 })
21
- * => /index.htm?by=recent&limit=20
22
- * ```
23
- * @return {String} url path(without host)
24
- */
25
- pathFor(name, params) {
26
- return this.app.router.url(name, params);
27
- }
28
- /**
29
- * Generate full URL(with host) for route. Takes the route name and a map of named params.
30
- * @function Helper#urlFor
31
- * @param {String} name - Router name
32
- * @param {Object} params - Other params
33
- * @example
34
- * ```js
35
- * app.get('home', '/index.htm', 'home.index');
36
- * ctx.helper.urlFor('home', { by: 'recent', limit: 20 })
37
- * => http://127.0.0.1:7001/index.htm?by=recent&limit=20
38
- * ```
39
- * @return {String} full url(with host)
40
- */
41
- urlFor(name, params) {
42
- return this.ctx.protocol + "://" + this.ctx.host + url.resolve("/", this.pathFor(name, params));
43
- }
44
- };
45
-
46
- //#endregion
47
- export { Helper };
@@ -1,36 +0,0 @@
1
- import { HttpClient } from "urllib";
2
- import { ms } from "humanize-ms";
3
-
4
- //#region src/lib/core/httpclient.ts
5
- var HttpClient$1 = class extends HttpClient {
6
- #app;
7
- constructor(app, options = {}) {
8
- normalizeConfig(app);
9
- const config = app.config.httpclient;
10
- const initOptions = {
11
- ...options,
12
- defaultArgs: {
13
- ...config.request,
14
- ...options.defaultArgs
15
- }
16
- };
17
- super(initOptions);
18
- this.#app = app;
19
- }
20
- async request(url, options) {
21
- options = options ?? {};
22
- if (options.ctx?.tracer) options.tracer = options.ctx.tracer;
23
- else options.tracer = options.tracer ?? this.#app.tracer;
24
- return await super.request(url, options);
25
- }
26
- async curl(url, options) {
27
- return await this.request(url, options);
28
- }
29
- };
30
- function normalizeConfig(app) {
31
- const config = app.config.httpclient;
32
- if (typeof config.request?.timeout === "string") config.request.timeout = ms(config.request.timeout);
33
- }
34
-
35
- //#endregion
36
- export { HttpClient$1 as HttpClient };
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1,31 +0,0 @@
1
- import { EggLoggers } from "egg-logger";
2
- import { setCustomLogger } from "onelogger";
3
-
4
- //#region src/lib/core/logger.ts
5
- function createLoggers(app) {
6
- const loggerOptions = {
7
- ...app.config.logger,
8
- type: app.type,
9
- localStorage: app.ctxStorage
10
- };
11
- if (app.config.env === "prod" && loggerOptions.level === "DEBUG" && !app.config.logger.allowDebugAtProd) loggerOptions.level = "INFO";
12
- const loggers = new EggLoggers({
13
- logger: loggerOptions,
14
- customLogger: app.config.customLogger
15
- });
16
- app.ready(() => {
17
- if (app.config.logger.disableConsoleAfterReady) {
18
- loggers.disableConsole();
19
- loggers.coreLogger.info("[egg:lib:core:logger] disable console log after app ready");
20
- }
21
- });
22
- for (const loggerName of Object.keys(loggers)) setCustomLogger(loggerName, loggers[loggerName]);
23
- app.lifecycle.registerBeforeClose(() => {
24
- for (const loggerName of Object.keys(loggers)) setCustomLogger(loggerName, void 0);
25
- });
26
- loggers.coreLogger.info("[egg:lib:core:logger] init all loggers with options: %j", loggerOptions);
27
- return loggers;
28
- }
29
-
30
- //#endregion
31
- export { createLoggers };
@@ -1,225 +0,0 @@
1
- import { Request } from "@eggjs/core";
2
- import querystring from "node:querystring";
3
-
4
- //#region src/app/extend/request.ts
5
- const QUERY_CACHE = Symbol("request query cache");
6
- const QUERIES_CACHE = Symbol("request queries cache");
7
- const PROTOCOL = Symbol("request protocol");
8
- const HOST = Symbol("request host");
9
- const IPS = Symbol("request ips");
10
- const RE_ARRAY_KEY = /[^[\]]+\[\]$/;
11
- var Request$1 = class extends Request {
12
- /**
13
- * Parse the "Host" header field host
14
- * and support X-Forwarded-Host when a
15
- * proxy is enabled.
16
- * @member {String} Request#host
17
- * @example
18
- * ip + port
19
- * ```js
20
- * this.request.host
21
- * => '127.0.0.1:7001'
22
- * ```
23
- * or domain
24
- * ```js
25
- * this.request.host
26
- * => 'demo.eggjs.org'
27
- * ```
28
- */
29
- get host() {
30
- let host = this[HOST];
31
- if (host) return host;
32
- if (this.app.config.proxy) host = getFromHeaders(this, this.app.config.hostHeaders);
33
- host = host || this.get("host") || "";
34
- this[HOST] = host = host.split(",")[0].trim();
35
- return host;
36
- }
37
- /**
38
- * @member {String} Request#protocol
39
- * @example
40
- * ```js
41
- * this.request.protocol
42
- * => 'https'
43
- * ```
44
- */
45
- get protocol() {
46
- let protocol = this[PROTOCOL];
47
- if (protocol) return protocol;
48
- if (this.socket?.encrypted) {
49
- this[PROTOCOL] = protocol = "https";
50
- return protocol;
51
- }
52
- if (this.app.config.proxy) {
53
- const proto = getFromHeaders(this, this.app.config.protocolHeaders);
54
- if (proto) {
55
- this[PROTOCOL] = protocol = proto.split(/\s*,\s*/)[0];
56
- return protocol;
57
- }
58
- }
59
- this[PROTOCOL] = protocol = this.app.config.protocol || "http";
60
- return protocol;
61
- }
62
- /**
63
- * Get all pass through ip addresses from the request.
64
- * Enable only on `app.config.proxy = true`
65
- *
66
- * @member {Array} Request#ips
67
- * @example
68
- * ```js
69
- * this.request.ips
70
- * => ['100.23.1.2', '201.10.10.2']
71
- * ```
72
- */
73
- get ips() {
74
- let ips = this[IPS];
75
- if (ips) return ips;
76
- if (!this.app.config.proxy) {
77
- this[IPS] = ips = [];
78
- return ips;
79
- }
80
- const val = getFromHeaders(this, this.app.config.ipHeaders);
81
- this[IPS] = ips = val ? val.split(/\s*,\s*/) : [];
82
- let maxIpsCount = this.app.config.maxIpsCount;
83
- if (!maxIpsCount && this.app.config.maxProxyCount) maxIpsCount = this.app.config.maxProxyCount + 1;
84
- if (maxIpsCount > 0) this[IPS] = ips = ips.slice(-maxIpsCount);
85
- return ips;
86
- }
87
- /**
88
- * Get the request remote IPv4 address
89
- * @member {String} Request#ip
90
- * @return {String} IPv4 address
91
- * @example
92
- * ```js
93
- * this.request.ip
94
- * => '127.0.0.1'
95
- * => '111.10.2.1'
96
- * ```
97
- */
98
- get ip() {
99
- if (this._ip) return this._ip;
100
- const ip = this.ips[0] ?? this.socket.remoteAddress;
101
- this._ip = ip && ip.startsWith("::ffff:") ? ip.substring(7) : ip;
102
- return this._ip;
103
- }
104
- /**
105
- * Set the request remote IPv4 address
106
- * @member {String} Request#ip
107
- * @param {String} ip - IPv4 address
108
- * @example
109
- * ```js
110
- * this.request.ip
111
- * => '127.0.0.1'
112
- * => '111.10.2.1'
113
- * ```
114
- */
115
- set ip(ip) {
116
- this._ip = ip;
117
- }
118
- /**
119
- * detect if response should be json
120
- * 1. url path ends with `.json`
121
- * 2. response type is set to json
122
- * 3. detect by request accept header
123
- *
124
- * @member {Boolean} Request#acceptJSON
125
- * @since 1.0.0
126
- */
127
- get acceptJSON() {
128
- if (this.path.endsWith(".json")) return true;
129
- if (this.response.type && this.response.type.indexOf("json") >= 0) return true;
130
- if (this.accepts("html", "text", "json") === "json") return true;
131
- return false;
132
- }
133
- _customQuery(cacheName, filter) {
134
- const str = this.querystring || "";
135
- let c = this[cacheName];
136
- if (!c) c = this[cacheName] = {};
137
- let cacheQuery = c[str];
138
- if (!cacheQuery) {
139
- cacheQuery = c[str] = {};
140
- const isQueries = cacheName === QUERIES_CACHE;
141
- const query = str ? querystring.parse(str) : {};
142
- for (const key in query) {
143
- if (!key) continue;
144
- const value = filter(query[key]);
145
- cacheQuery[key] = value;
146
- if (isQueries && RE_ARRAY_KEY.test(key)) {
147
- const subKey = key.substring(0, key.length - 2);
148
- if (!cacheQuery[subKey]) cacheQuery[subKey] = value;
149
- }
150
- }
151
- }
152
- return cacheQuery;
153
- }
154
- /**
155
- * get params pass by querystring, all values are of string type.
156
- * @member {Object} Request#query
157
- * @example
158
- * ```js
159
- * GET http://127.0.0.1:7001?name=Foo&age=20&age=21
160
- * this.query
161
- * => { 'name': 'Foo', 'age': '20' }
162
- *
163
- * GET http://127.0.0.1:7001?a=b&a=c&o[foo]=bar&b[]=1&b[]=2&e=val
164
- * this.query
165
- * =>
166
- * {
167
- * "a": "b",
168
- * "o[foo]": "bar",
169
- * "b[]": "1",
170
- * "e": "val"
171
- * }
172
- * ```
173
- */
174
- get query() {
175
- return this._customQuery(QUERY_CACHE, firstValue);
176
- }
177
- /**
178
- * get params pass by querystring, all value are Array type. {@link Request#query}
179
- * @member {Array} Request#queries
180
- * @example
181
- * ```js
182
- * GET http://127.0.0.1:7001?a=b&a=c&o[foo]=bar&b[]=1&b[]=2&e=val
183
- * this.queries
184
- * =>
185
- * {
186
- * "a": ["b", "c"],
187
- * "o[foo]": ["bar"],
188
- * "b[]": ["1", "2"],
189
- * "e": ["val"]
190
- * }
191
- * ```
192
- */
193
- get queries() {
194
- return this._customQuery(QUERIES_CACHE, arrayValue);
195
- }
196
- /**
197
- * Set query-string as an object.
198
- *
199
- * @function Request#query
200
- * @param {Object} obj set querystring and query object for request.
201
- */
202
- set query(obj) {
203
- this.querystring = querystring.stringify(obj);
204
- }
205
- };
206
- function firstValue(value) {
207
- if (Array.isArray(value)) value = value[0];
208
- return value;
209
- }
210
- function arrayValue(value) {
211
- if (!Array.isArray(value)) value = [value];
212
- return value;
213
- }
214
- function getFromHeaders(request, names) {
215
- if (!names) return "";
216
- const fields = names.split(/\s*,\s*/);
217
- for (const name of fields) {
218
- const value = request.get(name);
219
- if (value) return value;
220
- }
221
- return "";
222
- }
223
-
224
- //#endregion
225
- export { Request$1 as Request };
@@ -1,36 +0,0 @@
1
- import { Response } from "@eggjs/core";
2
-
3
- //#region src/app/extend/response.ts
4
- const REAL_STATUS = Symbol("response realStatus");
5
- var Response$1 = class extends Response {
6
- /**
7
- * Get or set a real status code.
8
- *
9
- * e.g.: Using 302 status redirect to the global error page
10
- * instead of show current 500 status page.
11
- * And access log should save 500 not 302,
12
- * then the `realStatus` can help us find out the real status code.
13
- * @member {Number} Response#realStatus
14
- * @return {Number} The status code to be set.
15
- */
16
- get realStatus() {
17
- if (this[REAL_STATUS]) return this[REAL_STATUS];
18
- return this.status;
19
- }
20
- /**
21
- * Set a real status code.
22
- *
23
- * e.g.: Using 302 status redirect to the global error page
24
- * instead of show current 500 status page.
25
- * And access log should save 500 not 302,
26
- * then the `realStatus` can help us find out the real status code.
27
- * @member {Number} Response#realStatus
28
- * @param {Number} status The status code to be set.
29
- */
30
- set realStatus(status) {
31
- this[REAL_STATUS] = status;
32
- }
33
- };
34
-
35
- //#endregion
36
- export { Response$1 as Response };
@@ -1,29 +0,0 @@
1
- import { Response } from "@eggjs/core";
2
-
3
- //#region src/app/extend/response.d.ts
4
- declare class Response$1 extends Response {
5
- /**
6
- * Get or set a real status code.
7
- *
8
- * e.g.: Using 302 status redirect to the global error page
9
- * instead of show current 500 status page.
10
- * And access log should save 500 not 302,
11
- * then the `realStatus` can help us find out the real status code.
12
- * @member {Number} Response#realStatus
13
- * @return {Number} The status code to be set.
14
- */
15
- get realStatus(): number;
16
- /**
17
- * Set a real status code.
18
- *
19
- * e.g.: Using 302 status redirect to the global error page
20
- * instead of show current 500 status page.
21
- * And access log should save 500 not 302,
22
- * then the `realStatus` can help us find out the real status code.
23
- * @member {Number} Response#realStatus
24
- * @param {Number} status The status code to be set.
25
- */
26
- set realStatus(status: number);
27
- }
28
- //#endregion
29
- export { Response$1 as Response };
@@ -1,3 +0,0 @@
1
- import { Singleton } from "@eggjs/core";
2
-
3
- export { Singleton };
@@ -1,35 +0,0 @@
1
- import { Agent } from "./agent-BfFWeJj4.js";
2
- import { Application } from "./application-DVwFQSa9.js";
3
- import path from "node:path";
4
- import { readJSON } from "utility";
5
- import { importModule } from "@eggjs/utils";
6
-
7
- //#region src/lib/start.ts
8
- /**
9
- * Start egg with single process
10
- */
11
- async function startEgg(options = {}) {
12
- options.baseDir = options.baseDir ?? process.cwd();
13
- options.mode = "single";
14
- if (!options.framework) try {
15
- options.framework = (await readJSON(path.join(options.baseDir, "package.json"))).egg.framework;
16
- } catch {}
17
- let AgentClass = Agent;
18
- let ApplicationClass = Application;
19
- if (options.framework) {
20
- const framework = await importModule(options.framework, { paths: [options.baseDir] });
21
- AgentClass = framework.Agent;
22
- ApplicationClass = framework.Application;
23
- }
24
- const agent = new AgentClass({ ...options });
25
- await agent.ready();
26
- const application = new ApplicationClass({ ...options });
27
- application.agent = agent;
28
- agent.application = application;
29
- await application.ready();
30
- application.messenger.broadcast("egg-ready");
31
- return application;
32
- }
33
-
34
- //#endregion
35
- export { startEgg };
@@ -1,32 +0,0 @@
1
- //#region src/lib/types.ts
2
- /**
3
- * Define configuration with type safety
4
- * @example
5
- * ```ts
6
- * import { defineConfig } from 'egg';
7
- *
8
- * export default defineConfig({
9
- * keys: 'my-keys',
10
- * middleware: []
11
- * });
12
- * ```
13
- */
14
- function defineConfig(config) {
15
- return config;
16
- }
17
- /**
18
- * Define configuration factory function with type safety
19
- * @example
20
- * ```ts
21
- * export default defineConfigFactory((appInfo): PartialEggConfig => ({
22
- * keys: appInfo.name + '_keys',
23
- * middleware: []
24
- * }));
25
- * ```
26
- */
27
- function defineConfigFactory(configFactory) {
28
- return configFactory;
29
- }
30
-
31
- //#endregion
32
- export { defineConfig, defineConfigFactory };
@@ -1,14 +0,0 @@
1
- import "@eggjs/development/types";
2
- import "@eggjs/i18n/types";
3
- import "@eggjs/jsonp/types";
4
- import "@eggjs/logrotator/types";
5
- import "@eggjs/multipart/types";
6
- import "@eggjs/onerror/types";
7
- import "@eggjs/schedule/types";
8
- import "@eggjs/security/types";
9
- import "@eggjs/session/types";
10
- import "@eggjs/static/types";
11
- import "@eggjs/view/types";
12
- import "@eggjs/watcher/types";
13
-
14
- export { };
@@ -1,12 +0,0 @@
1
- import "@eggjs/development/types";
2
- import "@eggjs/i18n/types";
3
- import "@eggjs/jsonp/types";
4
- import "@eggjs/logrotator/types";
5
- import "@eggjs/multipart/types";
6
- import "@eggjs/onerror/types";
7
- import "@eggjs/schedule/types";
8
- import "@eggjs/security/types";
9
- import "@eggjs/session/types";
10
- import "@eggjs/static/types";
11
- import "@eggjs/view/types";
12
- import "@eggjs/watcher/types";
@@ -1,48 +0,0 @@
1
- import util from "node:util";
2
- import { isAsyncFunction, isClass, isFunction, isGeneratorFunction, isPrimitive, isRegExp, isSymbol } from "is-type-of";
3
-
4
- //#region src/lib/core/utils.ts
5
- function convertObject(obj, ignore = []) {
6
- if (!Array.isArray(ignore)) ignore = [ignore];
7
- for (const key of Object.keys(obj)) obj[key] = convertValue(key, obj[key], ignore);
8
- return obj;
9
- }
10
- function convertValue(key, value, ignore) {
11
- if (value === null || value === void 0) return value;
12
- let hit = false;
13
- for (const matchKey of ignore) if (typeof matchKey === "string" && matchKey === key) {
14
- hit = true;
15
- break;
16
- } else if (isRegExp(matchKey) && matchKey.test(key)) {
17
- hit = true;
18
- break;
19
- }
20
- if (!hit) {
21
- if (isSymbol(value) || isRegExp(value) || value instanceof URL) return value.toString();
22
- if (isPrimitive(value) || Array.isArray(value)) return value;
23
- }
24
- if (Object.getPrototypeOf(value) === Object.prototype) return convertObject(value, ignore);
25
- const name = value.name || "anonymous";
26
- if (isClass(value)) return `<Class ${name}>`;
27
- if (isFunction(value)) {
28
- if (isGeneratorFunction(value)) return `<GeneratorFunction ${name}>`;
29
- if (isAsyncFunction(value)) return `<AsyncFunction ${name}>`;
30
- return `<Function ${name}>`;
31
- }
32
- const typeName = value.constructor.name;
33
- if (typeName) {
34
- if (Buffer.isBuffer(value) || typeof value === "string") return `<${typeName} len: ${value.length}>`;
35
- return `<${typeName}>`;
36
- }
37
- return util.format(value);
38
- }
39
- function safeParseURL(url) {
40
- try {
41
- return new URL(url);
42
- } catch {
43
- return null;
44
- }
45
- }
46
-
47
- //#endregion
48
- export { convertObject, safeParseURL };
@@ -1,14 +0,0 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
3
-
4
- //#region src/lib/utils.ts
5
- function getSourceDirname() {
6
- if (typeof __dirname !== "undefined") return path.dirname(__dirname);
7
- return path.dirname(path.dirname(fileURLToPath(import.meta.url)));
8
- }
9
- function getSourceFile(filename) {
10
- return path.join(getSourceDirname(), filename);
11
- }
12
-
13
- //#endregion
14
- export { getSourceDirname, getSourceFile };