egg 4.1.0-beta.34 → 4.1.0-beta.36

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 (101) hide show
  1. package/dist/agent.d.ts +7 -3
  2. package/dist/agent.js +10 -6
  3. package/dist/ajv.d.ts +1 -1
  4. package/dist/ajv.js +3 -2
  5. package/dist/aop.d.ts +1 -1
  6. package/dist/aop.js +3 -2
  7. package/dist/app/extend/context.d.ts +181 -178
  8. package/dist/app/extend/context.js +244 -259
  9. package/dist/app/extend/helper.d.ts +40 -35
  10. package/dist/app/extend/helper.js +45 -41
  11. package/dist/app/extend/request.d.ts +135 -131
  12. package/dist/app/extend/request.js +219 -258
  13. package/dist/app/extend/response.d.ts +28 -24
  14. package/dist/app/extend/response.js +36 -34
  15. package/dist/app/middleware/body_parser.d.ts +2 -2
  16. package/dist/app/middleware/body_parser.js +7 -3
  17. package/dist/app/middleware/meta.d.ts +8 -8
  18. package/dist/app/middleware/meta.js +15 -18
  19. package/dist/app/middleware/notfound.d.ts +8 -5
  20. package/dist/app/middleware/notfound.js +25 -28
  21. package/dist/app/middleware/override_method.d.ts +2 -2
  22. package/dist/app/middleware/override_method.js +7 -3
  23. package/dist/app/middleware/site_file.d.ts +11 -7
  24. package/dist/app/middleware/site_file.js +37 -52
  25. package/dist/config/config.default.d.ts +11 -6
  26. package/dist/config/config.default.js +258 -375
  27. package/dist/config/config.local.d.ts +6 -3
  28. package/dist/config/config.local.js +7 -8
  29. package/dist/config/config.unittest.d.ts +6 -3
  30. package/dist/config/config.unittest.js +10 -8
  31. package/dist/config/plugin.d.ts +6 -2
  32. package/dist/config/plugin.js +67 -131
  33. package/dist/dal.d.ts +1 -1
  34. package/dist/dal.js +3 -2
  35. package/dist/errors.d.ts +1 -1
  36. package/dist/errors.js +3 -2
  37. package/dist/helper.d.ts +1 -1
  38. package/dist/helper.js +3 -2
  39. package/dist/index.d.ts +24 -106
  40. package/dist/index.js +23 -89
  41. package/dist/lib/agent.d.ts +21 -15
  42. package/dist/lib/agent.js +53 -45
  43. package/dist/lib/application.d.ts +60 -54
  44. package/dist/lib/application.js +200 -250
  45. package/dist/lib/core/base_context_class.d.ts +23 -17
  46. package/dist/lib/core/base_context_class.js +17 -15
  47. package/dist/lib/core/base_context_logger.d.ts +39 -35
  48. package/dist/lib/core/base_context_logger.js +58 -60
  49. package/dist/lib/core/base_hook_class.d.ts +18 -11
  50. package/dist/lib/core/base_hook_class.js +26 -22
  51. package/dist/lib/core/context_httpclient.d.ts +21 -16
  52. package/dist/lib/core/context_httpclient.js +29 -26
  53. package/dist/lib/core/httpclient.d.ts +14 -12
  54. package/dist/lib/core/httpclient.js +34 -37
  55. package/dist/lib/core/logger.d.ts +7 -3
  56. package/dist/lib/core/logger.js +30 -36
  57. package/dist/lib/core/messenger/IMessenger.d.ts +53 -49
  58. package/dist/lib/core/messenger/IMessenger.js +1 -2
  59. package/dist/lib/core/messenger/base.d.ts +11 -7
  60. package/dist/lib/core/messenger/base.js +30 -29
  61. package/dist/lib/core/messenger/index.d.ts +10 -6
  62. package/dist/lib/core/messenger/index.js +11 -8
  63. package/dist/lib/core/messenger/ipc.d.ts +62 -57
  64. package/dist/lib/core/messenger/ipc.js +126 -138
  65. package/dist/lib/core/messenger/local.d.ts +63 -58
  66. package/dist/lib/core/messenger/local.js +126 -131
  67. package/dist/lib/core/utils.d.ts +5 -2
  68. package/dist/lib/core/utils.js +44 -66
  69. package/dist/lib/define.d.ts +72 -67
  70. package/dist/lib/define.js +54 -53
  71. package/dist/lib/egg.d.ts +283 -281
  72. package/dist/lib/egg.js +512 -573
  73. package/dist/lib/error/CookieLimitExceedError.d.ts +7 -4
  74. package/dist/lib/error/CookieLimitExceedError.js +15 -12
  75. package/dist/lib/error/MessageUnhandledRejectionError.d.ts +7 -4
  76. package/dist/lib/error/MessageUnhandledRejectionError.js +15 -12
  77. package/dist/lib/error/index.d.ts +3 -2
  78. package/dist/lib/error/index.js +4 -3
  79. package/dist/lib/loader/AgentWorkerLoader.d.ts +15 -10
  80. package/dist/lib/loader/AgentWorkerLoader.js +22 -18
  81. package/dist/lib/loader/AppWorkerLoader.d.ts +20 -15
  82. package/dist/lib/loader/AppWorkerLoader.js +35 -37
  83. package/dist/lib/loader/EggApplicationLoader.d.ts +7 -3
  84. package/dist/lib/loader/EggApplicationLoader.js +7 -4
  85. package/dist/lib/loader/index.d.ts +4 -3
  86. package/dist/lib/loader/index.js +5 -4
  87. package/dist/lib/start.d.ts +24 -20
  88. package/dist/lib/start.js +32 -42
  89. package/dist/lib/types.d.ts +288 -286
  90. package/dist/lib/types.js +2 -2
  91. package/dist/lib/types.plugin.d.ts +21 -21
  92. package/dist/lib/types.plugin.js +23 -24
  93. package/dist/orm.d.ts +1 -1
  94. package/dist/orm.js +3 -2
  95. package/dist/schedule.d.ts +2 -2
  96. package/dist/schedule.js +5 -5
  97. package/dist/transaction.d.ts +1 -1
  98. package/dist/transaction.js +3 -2
  99. package/dist/urllib.d.ts +1 -1
  100. package/dist/urllib.js +3 -2
  101. package/package.json +60 -64
@@ -1,43 +1,47 @@
1
- import url from 'node:url';
2
1
  import { BaseContextClass } from "../../lib/core/base_context_class.js";
2
+ import url from "node:url";
3
+
4
+ //#region src/app/extend/helper.ts
3
5
  /**
4
- * The Helper class which can be used as utility function.
5
- * We support developers to extend Helper through ${baseDir}/app/extend/helper.js ,
6
- * then you can use all method on `ctx.helper` that is a instance of Helper.
7
- */
8
- export default class Helper extends BaseContextClass {
9
- /**
10
- * Generate URL path(without host) for route. Takes the route name and a map of named params.
11
- * @function Helper#pathFor
12
- * @param {String} name - Router Name
13
- * @param {Object} params - Other params
14
- *
15
- * @example
16
- * ```js
17
- * app.get('home', '/index.htm', 'home.index');
18
- * ctx.helper.pathFor('home', { by: 'recent', limit: 20 })
19
- * => /index.htm?by=recent&limit=20
20
- * ```
21
- * @return {String} url path(without host)
22
- */
23
- pathFor(name, params) {
24
- return this.app.router.url(name, params);
25
- }
26
- /**
27
- * Generate full URL(with host) for route. Takes the route name and a map of named params.
28
- * @function Helper#urlFor
29
- * @param {String} name - Router name
30
- * @param {Object} params - Other params
31
- * @example
32
- * ```js
33
- * app.get('home', '/index.htm', 'home.index');
34
- * ctx.helper.urlFor('home', { by: 'recent', limit: 20 })
35
- * => http://127.0.0.1:7001/index.htm?by=recent&limit=20
36
- * ```
37
- * @return {String} full url(with host)
38
- */
39
- urlFor(name, params) {
40
- return this.ctx.protocol + '://' + this.ctx.host + url.resolve('/', this.pathFor(name, params));
41
- }
42
- }
43
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwcC9leHRlbmQvaGVscGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sR0FBRyxNQUFNLFVBQVUsQ0FBQztBQUUzQixPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxzQ0FBc0MsQ0FBQztBQUV4RTs7OztHQUlHO0FBQ0gsTUFBTSxDQUFDLE9BQU8sT0FBTyxNQUFPLFNBQVEsZ0JBQWdCO0lBQ2xEOzs7Ozs7Ozs7Ozs7O09BYUc7SUFDSCxPQUFPLENBQUMsSUFBWSxFQUFFLE1BQTJCO1FBQy9DLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLElBQUksRUFBRSxNQUFNLENBQUMsQ0FBQztJQUMzQyxDQUFDO0lBRUQ7Ozs7Ozs7Ozs7OztPQVlHO0lBQ0gsTUFBTSxDQUFDLElBQVksRUFBRSxNQUEyQjtRQUM5QyxPQUFPLElBQUksQ0FBQyxHQUFHLENBQUMsUUFBUSxHQUFHLEtBQUssR0FBRyxJQUFJLENBQUMsR0FBRyxDQUFDLElBQUksR0FBRyxHQUFHLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDO0lBQ2xHLENBQUM7Q0FDRiJ9
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 as default };
@@ -1,132 +1,136 @@
1
- import { Request as EggCoreRequest } from '@eggjs/core';
2
- import type { Application } from '../../lib/application.ts';
3
- import type Context from './context.ts';
4
- import Response from './response.ts';
5
- export default class Request extends EggCoreRequest {
6
- app: Application;
7
- ctx: Context;
8
- response: Response;
9
- /**
10
- * Request body, parsed from koa-bodyparser or @eggjs/multipart
11
- */
12
- body: any;
13
- /**
14
- * Parse the "Host" header field host
15
- * and support X-Forwarded-Host when a
16
- * proxy is enabled.
17
- * @member {String} Request#host
18
- * @example
19
- * ip + port
20
- * ```js
21
- * this.request.host
22
- * => '127.0.0.1:7001'
23
- * ```
24
- * or domain
25
- * ```js
26
- * this.request.host
27
- * => 'demo.eggjs.org'
28
- * ```
29
- */
30
- get host(): string;
31
- /**
32
- * @member {String} Request#protocol
33
- * @example
34
- * ```js
35
- * this.request.protocol
36
- * => 'https'
37
- * ```
38
- */
39
- get protocol(): string;
40
- /**
41
- * Get all pass through ip addresses from the request.
42
- * Enable only on `app.config.proxy = true`
43
- *
44
- * @member {Array} Request#ips
45
- * @example
46
- * ```js
47
- * this.request.ips
48
- * => ['100.23.1.2', '201.10.10.2']
49
- * ```
50
- */
51
- get ips(): string[];
52
- /**
53
- * Get the request remote IPv4 address
54
- * @member {String} Request#ip
55
- * @return {String} IPv4 address
56
- * @example
57
- * ```js
58
- * this.request.ip
59
- * => '127.0.0.1'
60
- * => '111.10.2.1'
61
- * ```
62
- */
63
- get ip(): string;
64
- /**
65
- * Set the request remote IPv4 address
66
- * @member {String} Request#ip
67
- * @param {String} ip - IPv4 address
68
- * @example
69
- * ```js
70
- * this.request.ip
71
- * => '127.0.0.1'
72
- * => '111.10.2.1'
73
- * ```
74
- */
75
- set ip(ip: string);
76
- /**
77
- * detect if response should be json
78
- * 1. url path ends with `.json`
79
- * 2. response type is set to json
80
- * 3. detect by request accept header
81
- *
82
- * @member {Boolean} Request#acceptJSON
83
- * @since 1.0.0
84
- */
85
- get acceptJSON(): boolean;
86
- _customQuery(cacheName: symbol, filter: (value: string | string[]) => string | string[]): Record<string, string | string[]>;
87
- /**
88
- * get params pass by querystring, all values are of string type.
89
- * @member {Object} Request#query
90
- * @example
91
- * ```js
92
- * GET http://127.0.0.1:7001?name=Foo&age=20&age=21
93
- * this.query
94
- * => { 'name': 'Foo', 'age': '20' }
95
- *
96
- * GET http://127.0.0.1:7001?a=b&a=c&o[foo]=bar&b[]=1&b[]=2&e=val
97
- * this.query
98
- * =>
99
- * {
100
- * "a": "b",
101
- * "o[foo]": "bar",
102
- * "b[]": "1",
103
- * "e": "val"
104
- * }
105
- * ```
106
- */
107
- get query(): Record<string, string>;
108
- /**
109
- * get params pass by querystring, all value are Array type. {@link Request#query}
110
- * @member {Array} Request#queries
111
- * @example
112
- * ```js
113
- * GET http://127.0.0.1:7001?a=b&a=c&o[foo]=bar&b[]=1&b[]=2&e=val
114
- * this.queries
115
- * =>
116
- * {
117
- * "a": ["b", "c"],
118
- * "o[foo]": ["bar"],
119
- * "b[]": ["1", "2"],
120
- * "e": ["val"]
121
- * }
122
- * ```
123
- */
124
- get queries(): Record<string, string[]>;
125
- /**
126
- * Set query-string as an object.
127
- *
128
- * @function Request#query
129
- * @param {Object} obj set querystring and query object for request.
130
- */
131
- set query(obj: Record<string, string>);
1
+ import Response$1 from "./response.js";
2
+ import Context$1 from "./context.js";
3
+ import { Application } from "../../lib/application.js";
4
+ import { Request as Request$1 } from "@eggjs/core";
5
+
6
+ //#region src/app/extend/request.d.ts
7
+ declare class Request extends Request$1 {
8
+ app: Application;
9
+ ctx: Context$1;
10
+ response: Response$1;
11
+ /**
12
+ * Request body, parsed from koa-bodyparser or @eggjs/multipart
13
+ */
14
+ body: any;
15
+ /**
16
+ * Parse the "Host" header field host
17
+ * and support X-Forwarded-Host when a
18
+ * proxy is enabled.
19
+ * @member {String} Request#host
20
+ * @example
21
+ * ip + port
22
+ * ```js
23
+ * this.request.host
24
+ * => '127.0.0.1:7001'
25
+ * ```
26
+ * or domain
27
+ * ```js
28
+ * this.request.host
29
+ * => 'demo.eggjs.org'
30
+ * ```
31
+ */
32
+ get host(): string;
33
+ /**
34
+ * @member {String} Request#protocol
35
+ * @example
36
+ * ```js
37
+ * this.request.protocol
38
+ * => 'https'
39
+ * ```
40
+ */
41
+ get protocol(): string;
42
+ /**
43
+ * Get all pass through ip addresses from the request.
44
+ * Enable only on `app.config.proxy = true`
45
+ *
46
+ * @member {Array} Request#ips
47
+ * @example
48
+ * ```js
49
+ * this.request.ips
50
+ * => ['100.23.1.2', '201.10.10.2']
51
+ * ```
52
+ */
53
+ get ips(): string[];
54
+ /**
55
+ * Get the request remote IPv4 address
56
+ * @member {String} Request#ip
57
+ * @return {String} IPv4 address
58
+ * @example
59
+ * ```js
60
+ * this.request.ip
61
+ * => '127.0.0.1'
62
+ * => '111.10.2.1'
63
+ * ```
64
+ */
65
+ get ip(): string;
66
+ /**
67
+ * Set the request remote IPv4 address
68
+ * @member {String} Request#ip
69
+ * @param {String} ip - IPv4 address
70
+ * @example
71
+ * ```js
72
+ * this.request.ip
73
+ * => '127.0.0.1'
74
+ * => '111.10.2.1'
75
+ * ```
76
+ */
77
+ set ip(ip: string);
78
+ /**
79
+ * detect if response should be json
80
+ * 1. url path ends with `.json`
81
+ * 2. response type is set to json
82
+ * 3. detect by request accept header
83
+ *
84
+ * @member {Boolean} Request#acceptJSON
85
+ * @since 1.0.0
86
+ */
87
+ get acceptJSON(): boolean;
88
+ _customQuery(cacheName: symbol, filter: (value: string | string[]) => string | string[]): Record<string, string | string[]>;
89
+ /**
90
+ * get params pass by querystring, all values are of string type.
91
+ * @member {Object} Request#query
92
+ * @example
93
+ * ```js
94
+ * GET http://127.0.0.1:7001?name=Foo&age=20&age=21
95
+ * this.query
96
+ * => { 'name': 'Foo', 'age': '20' }
97
+ *
98
+ * GET http://127.0.0.1:7001?a=b&a=c&o[foo]=bar&b[]=1&b[]=2&e=val
99
+ * this.query
100
+ * =>
101
+ * {
102
+ * "a": "b",
103
+ * "o[foo]": "bar",
104
+ * "b[]": "1",
105
+ * "e": "val"
106
+ * }
107
+ * ```
108
+ */
109
+ get query(): Record<string, string>;
110
+ /**
111
+ * get params pass by querystring, all value are Array type. {@link Request#query}
112
+ * @member {Array} Request#queries
113
+ * @example
114
+ * ```js
115
+ * GET http://127.0.0.1:7001?a=b&a=c&o[foo]=bar&b[]=1&b[]=2&e=val
116
+ * this.queries
117
+ * =>
118
+ * {
119
+ * "a": ["b", "c"],
120
+ * "o[foo]": ["bar"],
121
+ * "b[]": ["1", "2"],
122
+ * "e": ["val"]
123
+ * }
124
+ * ```
125
+ */
126
+ get queries(): Record<string, string[]>;
127
+ /**
128
+ * Set query-string as an object.
129
+ *
130
+ * @function Request#query
131
+ * @param {Object} obj set querystring and query object for request.
132
+ */
133
+ set query(obj: Record<string, string>);
132
134
  }
135
+ //#endregion
136
+ export { Request as default };