egg 2.33.1 → 2.36.0
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/README.md +7 -3
- package/README.zh-CN.md +3 -3
- package/app/middleware/site_file.js +1 -2
- package/config/config.default.js +3 -0
- package/lib/application.js +1 -1
- package/lib/core/dnscache_httpclient.js +2 -2
- package/lib/egg.js +8 -1
- package/package.json +13 -6
- package/History.md +0 -1973
package/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<div style="text-align:center">
|
|
2
|
-
<img src="
|
|
2
|
+
<img src="site/public/assets/egg-banner.png" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
[](https://npmjs.org/package/egg)
|
|
6
6
|
[](http://packagequality.com/#?package=egg)
|
|
7
7
|
[](https://npmjs.org/package/egg)
|
|
8
|
+
[](https://app.fossa.com/projects/git%2Bgithub.com%2Feggjs%2Fegg?ref=badge_shield)
|
|
8
9
|
|
|
9
10
|
[](https://github.com/eggjs/egg/actions?query=branch%3Amaster)
|
|
10
11
|
[](https://codecov.io/gh/eggjs/egg)
|
|
@@ -31,7 +32,7 @@ $ npm run dev
|
|
|
31
32
|
$ open http://localhost:7001
|
|
32
33
|
```
|
|
33
34
|
|
|
34
|
-
> Node.js >= 8.
|
|
35
|
+
> Node.js >= 8.5.0 required.
|
|
35
36
|
|
|
36
37
|
## Documentations
|
|
37
38
|
|
|
@@ -42,7 +43,7 @@ $ open http://localhost:7001
|
|
|
42
43
|
|
|
43
44
|
## Contributors
|
|
44
45
|
|
|
45
|
-
[](https://github.com/eggjs/egg/graphs/contributors)
|
|
46
47
|
|
|
47
48
|
## How to Contribute
|
|
48
49
|
|
|
@@ -58,3 +59,6 @@ To become a contributor, please follow our [contributing guide](CONTRIBUTING.md)
|
|
|
58
59
|
## License
|
|
59
60
|
|
|
60
61
|
[MIT](LICENSE)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
[](https://app.fossa.com/projects/git%2Bgithub.com%2Feggjs%2Fegg?ref=badge_large)
|
package/README.zh-CN.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div style="text-align:center">
|
|
2
|
-
<img src="
|
|
2
|
+
<img src="site/public/assets/egg-banner.png" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
[](https://npmjs.org/package/egg)
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
- 深度框架定制
|
|
19
19
|
- 丰富的[插件](https://github.com/search?q=topic%3Aegg-plugin&type=Repositories)
|
|
20
20
|
|
|
21
|
-
> 支持 Node.js 8.x 及以上版本。
|
|
21
|
+
> 支持 Node.js 8.5.x 及以上版本。
|
|
22
22
|
|
|
23
23
|
## 快速开始
|
|
24
24
|
|
|
@@ -39,7 +39,7 @@ $ open http://localhost:7001
|
|
|
39
39
|
|
|
40
40
|
## 贡献者
|
|
41
41
|
|
|
42
|
-
[](https://github.com/eggjs/egg/graphs/contributors)
|
|
43
43
|
|
|
44
44
|
## 贡献代码
|
|
45
45
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const MAX_AGE = 'public, max-age=2592000'; // 30 days
|
|
5
4
|
|
|
6
5
|
module.exports = options => {
|
|
7
6
|
return function siteFile(ctx, next) {
|
|
@@ -19,7 +18,7 @@ module.exports = options => {
|
|
|
19
18
|
// '/robots.txt': Buffer <xx..
|
|
20
19
|
// content is buffer
|
|
21
20
|
if (Buffer.isBuffer(content)) {
|
|
22
|
-
ctx.set('cache-control',
|
|
21
|
+
ctx.set('cache-control', options.cacheControl);
|
|
23
22
|
ctx.body = content;
|
|
24
23
|
ctx.type = path.extname(ctx.path);
|
|
25
24
|
return;
|
package/config/config.default.js
CHANGED
|
@@ -190,6 +190,7 @@ module.exports = appInfo => {
|
|
|
190
190
|
* You can map some files using this options, it will response immdiately when matching.
|
|
191
191
|
*
|
|
192
192
|
* @member {Object} Config#siteFile - key is path, and value is url or buffer.
|
|
193
|
+
* @property {String} cacheControl - files cache , default is public, max-age=2592000
|
|
193
194
|
* @example
|
|
194
195
|
* // specific app's favicon, => '/favicon.ico': 'https://eggjs.org/favicon.ico',
|
|
195
196
|
* config.siteFile = {
|
|
@@ -198,6 +199,8 @@ module.exports = appInfo => {
|
|
|
198
199
|
*/
|
|
199
200
|
config.siteFile = {
|
|
200
201
|
'/favicon.ico': fs.readFileSync(path.join(__dirname, 'favicon.png')),
|
|
202
|
+
// default cache in 30 days
|
|
203
|
+
cacheControl: 'public, max-age=2592000',
|
|
201
204
|
};
|
|
202
205
|
|
|
203
206
|
/**
|
package/lib/application.js
CHANGED
|
@@ -127,7 +127,7 @@ class Application extends EggApplication {
|
|
|
127
127
|
if (typeof this.config.onClientError === 'function') {
|
|
128
128
|
const p = eggUtils.callFn(this.config.onClientError, [ err, socket, this ]);
|
|
129
129
|
|
|
130
|
-
// the returned object should like:
|
|
130
|
+
// the returned object should be something like:
|
|
131
131
|
//
|
|
132
132
|
// {
|
|
133
133
|
// body: '...',
|
|
@@ -71,7 +71,7 @@ class DNSCacheHttpClient extends HttpClient {
|
|
|
71
71
|
|
|
72
72
|
args = args || {};
|
|
73
73
|
args.headers = args.headers || {};
|
|
74
|
-
// set host header
|
|
74
|
+
// set when host header doesn't exist
|
|
75
75
|
if (!args.headers.host && !args.headers.Host) {
|
|
76
76
|
// host must combine with hostname:port, node won't use `parsed.host`
|
|
77
77
|
args.headers.host = parsed.port ? `${hostname}:${parsed.port}` : hostname;
|
|
@@ -81,7 +81,7 @@ class DNSCacheHttpClient extends HttpClient {
|
|
|
81
81
|
const now = Date.now();
|
|
82
82
|
if (record) {
|
|
83
83
|
if (now - record.timestamp >= this.dnsCacheLookupInterval) {
|
|
84
|
-
// make sure next request
|
|
84
|
+
// make sure the next request doesn't refresh dns query
|
|
85
85
|
record.timestamp = now;
|
|
86
86
|
this[UPDATE_DNS](hostname, args).catch(err => this.app.emit('error', err));
|
|
87
87
|
}
|
package/lib/egg.js
CHANGED
|
@@ -373,7 +373,7 @@ class EggApplication extends EggCore {
|
|
|
373
373
|
ignoreList = [];
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
-
const json = extend(true, {}, { config: this.config, plugins: this.loader.allPlugins });
|
|
376
|
+
const json = extend(true, {}, { config: this.config, plugins: this.loader.allPlugins, appInfo: this.loader.appInfo });
|
|
377
377
|
utils.convertObject(json, ignoreList);
|
|
378
378
|
return {
|
|
379
379
|
config: json,
|
|
@@ -426,6 +426,13 @@ class EggApplication extends EggCore {
|
|
|
426
426
|
_setupTimeoutTimer() {
|
|
427
427
|
const startTimeoutTimer = setTimeout(() => {
|
|
428
428
|
this.coreLogger.error(`${this.type} still doesn't ready after ${this.config.workerStartTimeout} ms.`);
|
|
429
|
+
// log unfinished
|
|
430
|
+
const json = this.timing.toJSON();
|
|
431
|
+
for (const item of json) {
|
|
432
|
+
if (item.end) continue;
|
|
433
|
+
this.coreLogger.error(`unfinished timing item: ${CircularJSON.stringify(item)}`);
|
|
434
|
+
}
|
|
435
|
+
this.coreLogger.error(`check run/${this.type}_timing_${process.pid}.json for more details.`);
|
|
429
436
|
this.emit('startTimeout');
|
|
430
437
|
}, this.config.workerStartTimeout);
|
|
431
438
|
this.ready(() => clearTimeout(startTimeoutTimer));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "egg",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.36.0",
|
|
4
4
|
"description": "A web framework's framework for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web",
|
|
@@ -57,15 +57,19 @@
|
|
|
57
57
|
"ylru": "^1.2.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
+
"@umijs/preset-react": "^2.1.2",
|
|
60
61
|
"address": "^1.0.3",
|
|
62
|
+
"antd": "^4.18.6",
|
|
61
63
|
"assert-extends": "^1.0.1",
|
|
62
64
|
"assert-file": "^1.0.0",
|
|
63
65
|
"autod": "^3.0.1",
|
|
64
66
|
"autod-egg": "^1.1.0",
|
|
65
67
|
"coffee": "^5.2.1",
|
|
68
|
+
"dumi": "^1.1.38",
|
|
69
|
+
"dumi-theme-egg": "^1.2.0",
|
|
66
70
|
"egg-alinode": "^1.0.3",
|
|
67
71
|
"egg-bin": "^4.12.3",
|
|
68
|
-
"egg-doctools": "^2.
|
|
72
|
+
"egg-doctools": "^2.9.1",
|
|
69
73
|
"egg-mock": "^3.21.0",
|
|
70
74
|
"egg-plugin-puml": "^2.4.0",
|
|
71
75
|
"egg-tracer": "^1.1.0",
|
|
@@ -75,11 +79,13 @@
|
|
|
75
79
|
"findlinks": "^2.1.0",
|
|
76
80
|
"formstream": "^1.1.0",
|
|
77
81
|
"glob": "^7.1.3",
|
|
82
|
+
"jsdoc": "^3.6.10",
|
|
78
83
|
"koa": "^2.11.0",
|
|
79
84
|
"koa-static": "^3.0.0",
|
|
80
85
|
"mz": "^2.7.0",
|
|
81
86
|
"mz-modules": "^2.1.0",
|
|
82
87
|
"pedding": "^1.1.0",
|
|
88
|
+
"prettier": "^2.5.1",
|
|
83
89
|
"runscript": "^1.3.0",
|
|
84
90
|
"spy": "^1.0.0",
|
|
85
91
|
"supertest": "^3.4.2",
|
|
@@ -103,11 +109,12 @@
|
|
|
103
109
|
"test-local-changed": "egg-bin test --changed",
|
|
104
110
|
"cov": "egg-bin cov --timeout 100000",
|
|
105
111
|
"ci": "npm run lint && egg-bin pkgfiles --check && npm run cov",
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
112
|
+
"site:jsdoc": "node ./scripts/jsdoc.js",
|
|
113
|
+
"site:dev": "APP_ROOT=./site dumi dev",
|
|
114
|
+
"site:build": "APP_ROOT=./site dumi build && npm run site:jsdoc",
|
|
115
|
+
"site:prettier": "prettier --config site/.prettierrc --ignore-path site/.prettierignore --write \"site/**/*.{js,jsx,tsx,ts,less,md,json}\"",
|
|
109
116
|
"autod": "autod",
|
|
110
|
-
"puml": "puml . --dest ./
|
|
117
|
+
"puml": "puml . --dest ./site",
|
|
111
118
|
"commits": "./scripts/commits.sh"
|
|
112
119
|
},
|
|
113
120
|
"homepage": "https://github.com/eggjs/egg",
|