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.
- package/dist/agent.d.ts +7 -3
- package/dist/agent.js +10 -6
- package/dist/ajv.d.ts +1 -1
- package/dist/ajv.js +3 -2
- package/dist/aop.d.ts +1 -1
- package/dist/aop.js +3 -2
- package/dist/app/extend/context.d.ts +181 -178
- package/dist/app/extend/context.js +244 -259
- package/dist/app/extend/helper.d.ts +40 -35
- package/dist/app/extend/helper.js +45 -41
- package/dist/app/extend/request.d.ts +135 -131
- package/dist/app/extend/request.js +219 -258
- package/dist/app/extend/response.d.ts +28 -24
- package/dist/app/extend/response.js +36 -34
- package/dist/app/middleware/body_parser.d.ts +2 -2
- package/dist/app/middleware/body_parser.js +7 -3
- package/dist/app/middleware/meta.d.ts +8 -8
- package/dist/app/middleware/meta.js +15 -18
- package/dist/app/middleware/notfound.d.ts +8 -5
- package/dist/app/middleware/notfound.js +25 -28
- package/dist/app/middleware/override_method.d.ts +2 -2
- package/dist/app/middleware/override_method.js +7 -3
- package/dist/app/middleware/site_file.d.ts +11 -7
- package/dist/app/middleware/site_file.js +37 -52
- package/dist/config/config.default.d.ts +11 -6
- package/dist/config/config.default.js +258 -375
- package/dist/config/config.local.d.ts +6 -3
- package/dist/config/config.local.js +7 -8
- package/dist/config/config.unittest.d.ts +6 -3
- package/dist/config/config.unittest.js +10 -8
- package/dist/config/plugin.d.ts +6 -2
- package/dist/config/plugin.js +67 -131
- package/dist/dal.d.ts +1 -1
- package/dist/dal.js +3 -2
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +3 -2
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +3 -2
- package/dist/index.d.ts +24 -106
- package/dist/index.js +23 -89
- package/dist/lib/agent.d.ts +21 -15
- package/dist/lib/agent.js +53 -45
- package/dist/lib/application.d.ts +60 -54
- package/dist/lib/application.js +200 -250
- package/dist/lib/core/base_context_class.d.ts +23 -17
- package/dist/lib/core/base_context_class.js +17 -15
- package/dist/lib/core/base_context_logger.d.ts +39 -35
- package/dist/lib/core/base_context_logger.js +58 -60
- package/dist/lib/core/base_hook_class.d.ts +18 -11
- package/dist/lib/core/base_hook_class.js +26 -22
- package/dist/lib/core/context_httpclient.d.ts +21 -16
- package/dist/lib/core/context_httpclient.js +29 -26
- package/dist/lib/core/httpclient.d.ts +14 -12
- package/dist/lib/core/httpclient.js +34 -37
- package/dist/lib/core/logger.d.ts +7 -3
- package/dist/lib/core/logger.js +30 -36
- package/dist/lib/core/messenger/IMessenger.d.ts +53 -49
- package/dist/lib/core/messenger/IMessenger.js +1 -2
- package/dist/lib/core/messenger/base.d.ts +11 -7
- package/dist/lib/core/messenger/base.js +30 -29
- package/dist/lib/core/messenger/index.d.ts +10 -6
- package/dist/lib/core/messenger/index.js +11 -8
- package/dist/lib/core/messenger/ipc.d.ts +62 -57
- package/dist/lib/core/messenger/ipc.js +126 -138
- package/dist/lib/core/messenger/local.d.ts +63 -58
- package/dist/lib/core/messenger/local.js +126 -131
- package/dist/lib/core/utils.d.ts +5 -2
- package/dist/lib/core/utils.js +44 -66
- package/dist/lib/define.d.ts +72 -67
- package/dist/lib/define.js +54 -53
- package/dist/lib/egg.d.ts +283 -281
- package/dist/lib/egg.js +512 -573
- package/dist/lib/error/CookieLimitExceedError.d.ts +7 -4
- package/dist/lib/error/CookieLimitExceedError.js +15 -12
- package/dist/lib/error/MessageUnhandledRejectionError.d.ts +7 -4
- package/dist/lib/error/MessageUnhandledRejectionError.js +15 -12
- package/dist/lib/error/index.d.ts +3 -2
- package/dist/lib/error/index.js +4 -3
- package/dist/lib/loader/AgentWorkerLoader.d.ts +15 -10
- package/dist/lib/loader/AgentWorkerLoader.js +22 -18
- package/dist/lib/loader/AppWorkerLoader.d.ts +20 -15
- package/dist/lib/loader/AppWorkerLoader.js +35 -37
- package/dist/lib/loader/EggApplicationLoader.d.ts +7 -3
- package/dist/lib/loader/EggApplicationLoader.js +7 -4
- package/dist/lib/loader/index.d.ts +4 -3
- package/dist/lib/loader/index.js +5 -4
- package/dist/lib/start.d.ts +24 -20
- package/dist/lib/start.js +32 -42
- package/dist/lib/types.d.ts +288 -286
- package/dist/lib/types.js +2 -2
- package/dist/lib/types.plugin.d.ts +21 -21
- package/dist/lib/types.plugin.js +23 -24
- package/dist/orm.d.ts +1 -1
- package/dist/orm.js +3 -2
- package/dist/schedule.d.ts +2 -2
- package/dist/schedule.js +5 -5
- package/dist/transaction.d.ts +1 -1
- package/dist/transaction.js +3 -2
- package/dist/urllib.d.ts +1 -1
- package/dist/urllib.js +3 -2
- 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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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 };
|