You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: History.md
+84Lines changed: 84 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,89 @@
1
1
# History
2
2
3
+
## 2018-05-03, Version 2.8.0 @dead-horse
4
+
5
+
### Notable changes
6
+
7
+
***feature**
8
+
* add time duration for dump config
9
+
10
+
***fix**
11
+
* make singleton work for unextensible or frozen instance
12
+
13
+
***docs**
14
+
* switch to English document
15
+
* add middleware to Application and other ts improvement (typescript)
16
+
* update wxapp-socket-io project to weapp.socket.io
17
+
* update title and remove unused files
18
+
19
+
### Commits
20
+
21
+
*[[`4b602d037`](http://github.com/eggjs/egg/commit/4b602d037554b72c8261b7abb7efd94f8f59f3fe)] - fix: make singleton work for unextensible or frozen instance (#2472) (Yiyu He <<dead_horse@qq.com>>)
22
+
*[[`824200c11`](http://github.com/eggjs/egg/commit/824200c11cac8e20b2c275daa7f5a4a365c71259)] - feat: add time duration for dump config (#2485) (Haoliang Gao <<sakura9515@gmail.com>>)
*[[`1ada8e384`](http://github.com/eggjs/egg/commit/1ada8e3848be9f09680d7cac091fb14206df5a11)] - feat(d.ts): add middleware to Application and other ts improvement (#2465) (Axes <<whxaxes@qq.com>>)
25
+
*[[`437785315`](http://github.com/eggjs/egg/commit/437785315f28a828ea0cf7bece80223d5b796dc5)] - docs: fix the code error of LOCALS in view.md (#2464) (zjz19901029 <<346663801@qq.com>>)
26
+
*[[`f341b9fb8`](http://github.com/eggjs/egg/commit/f341b9fb8bdf36b6280500578e8448c59aec10f1)] - chore: update title and remove unused files (#2433) (TZ |
27
+
天猪 <<atian25@qq.com>>)
28
+
*[[`a5ab29cbd`](http://github.com/eggjs/egg/commit/a5ab29cbd1de0f5425019085258a496b4bce8b45)] - docs: switch to English document (#2426) (Haoliang Gao <<sakura9515@gmail.com>>)
29
+
*[[`4ab7df25f`](http://github.com/eggjs/egg/commit/4ab7df25f152609d494745eac2794b78e66444f0)] - deps: update dependencies, add @types/urllib to autod config (#2423) (Yiyu He <<dead_horse@qq.com>>)
30
+
31
+
## 2018-04-17, Version 2.7.1 @dead-horse
32
+
33
+
### Notable changes
34
+
35
+
***fix**
36
+
* imporve compatibility of singleton
37
+
38
+
### Commits
39
+
40
+
*[[`e4d219f`](http://github.com/eggjs/egg/commit/e4d219f1aaecbca13601c7813e57c67934e8c32b)] - fix: imporve compatibility of singleton (#2410) (Yiyu He <<dead_horse@qq.com>>)
41
+
42
+
## 2018-04-16, Version 2.7.0 @dead-horse[DEPRECATED]
43
+
44
+
### Notable changes
45
+
46
+
***feature**
47
+
* singleton support asynchronous create function
48
+
49
+
***fix**
50
+
* dump config support circular json
51
+
52
+
***docs**
53
+
* improve router and typescript
54
+
55
+
### Commits
56
+
57
+
*[[`3d499a9`](http://github.com/eggjs/egg/commit/3d499a90bab7095569e115e223de40e63812f2f5)] - docs(plugin): add singleton support async create function (#2392) (Yiyu He <<dead_horse@qq.com>>)
58
+
*[[`05d925f`](http://github.com/eggjs/egg/commit/05d925fea4e0b2d8efa48cb01ced2133c0c059cd)] - docs: change English document on Readme (#2397) (Haoliang Gao <<sakura9515@gmail.com>>)
59
+
*[[`590bd8c`](http://github.com/eggjs/egg/commit/590bd8cb400845706ec7cc84232b812cb468c8ac)] - fix: dumpConfig support circular json (#2394) (Yiyu He <<dead_horse@qq.com>>)
60
+
*[[`3a489b6`](http://github.com/eggjs/egg/commit/3a489b6f47b39ff2ec31efe936504918300b3f08)] - feat(singleton): support async create function (#2382) (Yiyu He <<dead_horse@qq.com>>)
61
+
*[[`a5b6731`](http://github.com/eggjs/egg/commit/a5b673133b35e9b005e19c1e3267a2ff3d58e32b)] - docs: chore for router and typescript (#2390) (TZ | 天猪 <<atian25@qq.com>>)
*[[`2998bf733`](http://github.com/eggjs/egg/commit/2998bf733268d4d88d5fc77e05943b3fa0f824d4)] - chore(typings): add index signature of EggAppConfig (#2359) (waiting <<waiting@xiaozhong.biz>>)
77
+
*[[`5f2358bbd`](http://github.com/eggjs/egg/commit/5f2358bbdd6e21a1ab387a8425d0fefc30954227)] - docs: intro session.renew in the doc (#2375) (Yiyu He <<dead_horse@qq.com>>)
*[[`84e0dc4e7`](http://github.com/eggjs/egg/commit/84e0dc4e74e4e907d39b5485e1b19c3900aec393)] - fix(d.ts): add modifier to plugin and add middleware to config (#2322) (Axes <<whxaxes@qq.com>>)
> All the documentations (comments, README, etc.) are in English, except the tutorials and api documentations are still [being translated](https://github.com/eggjs/egg/issues/363).
54
-
> Feel free to join us and translate egg documentations. It's appreciated.
@@ -273,7 +273,7 @@ If each plugin makes their own implementation, all sorts of configs and initia
273
273
274
274
#### Writing Plugin
275
275
276
-
We simplify the [egg-mysql] plugin and to see how to write such a plugin:
276
+
We simplify the [egg-mysql] plugin and to see how to write such a plugin:
277
277
278
278
```js
279
279
// egg-mysql/app.js
@@ -284,7 +284,7 @@ module.exports = app => {
284
284
}
285
285
286
286
/**
287
-
* @param{Object}config The config which already processed by the framework. If the application configured multiple MySQL instances, each config would be passed in and call multiple createMysql
287
+
* @param{Object}config The config which already processed by the framework. If the application configured multiple MySQL instances, each config would be passed in and call multiple createMysql
288
288
* @param{Application}app the current application
289
289
* @return{Object} return the created MySQL instance
290
290
*/
@@ -294,16 +294,33 @@ function createMysql(config, app) {
294
294
constclient=newMysql(config);
295
295
296
296
// check before start the application
297
-
app.beforeStart(asyncfunctionstartMysql() {
297
+
app.beforeStart(async() => {
298
298
constrows=awaitclient.query('select now() as currentTime;');
299
-
constindex= count++;
300
-
app.coreLogger.info(`[egg-mysql] instance[${index}] status OK, rds currentTime: ${rows[0].currentTime}`);
The initialization function also support `Async function`, convenient for some special plugins that need to be asynchronous to get some configuration files.
As you can see, all we need to do for this plugin is passing in the field that need to be mounted and the corresponding initialization function. Framework will be in charge of managing all the configs and the ways to access the instances.
308
325
309
326
#### Application Layer Usage Case
@@ -366,7 +383,7 @@ exports.mysql = {
366
383
};
367
384
```
368
385
369
-
2. Access the corresponding instance by `app.mysql.get('db1')`
386
+
2. Access the corresponding instance by `app.mysql.get('db1')`
370
387
371
388
```js
372
389
// app/controller/post.js
@@ -388,12 +405,12 @@ module.exports = app => {
388
405
// get MySQL config from configuration center { host, post, password, ... }
@@ -455,7 +472,7 @@ We are very welcome your contribution to the new plugins, but also hope you foll
455
472
456
473
Egg defines the plugin name through the `eggPlugin.name`, it is only unique in application or framework, that means **many npm packages might get the same plugin name**, why design in this way?
457
474
458
-
First, Egg plugin do not only support npm package, it also supports search plugins in local directory. In Chapter [progressive](../tutorials/progressive.md) we mentioned how to make progress by using these two configurations. Directory is more friendly to unit test. So, Egg can not ensure uniqueness through npm package name.
475
+
First, Egg plugin do not only support npm package, it also supports search plugins in local directory. In Chapter [progressive](../tutorials/progressive.md) we mentioned how to make progress by using these two configurations. Directory is more friendly to unit test. So, Egg can not ensure uniqueness through npm package name.
459
476
460
477
What's more, Egg can use this feature to make Adapter. For example, the plugin defined in[Template Develop Spec](./view-plugin.md#PluginNameSpecification) was named as view, but there are plugins named `egg-view-nunjucks` and `egg-view-react`, the users only need to change the plugin and modify the templates, no need to modify the Controller, because all these plugins have implemented the same API.
Copy file name to clipboardExpand all lines: docs/source/en/basics/controller.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -920,3 +920,22 @@ class ProxyController extends Controller {
920
920
}
921
921
}
922
922
```
923
+
924
+
### Redirect
925
+
926
+
The framework overwrites koa's native `ctx.redirect` implementation with a security plugin to provide a more secure redirect.
927
+
928
+
929
+
*`ctx.redirect(url)` Forbids redirect if it is not in the configured whitelist domain name.
930
+
*`ctx.unsafeRedirect(url)` does not determine the domain name and redirect directly. Generally, it is not recommended to use it. Use it after clearly understanding the possible risks.
931
+
932
+
If you use the `ctx.redirect` method, you need to configure the application configuration file as follows:
933
+
934
+
```js
935
+
// config/config.default.js
936
+
exports.security= {
937
+
domainWhiteList:['.domain.com'], // Security whitelist, starts with `.`
938
+
};
939
+
```
940
+
941
+
If the user does not configure the `domainWhiteList` or the `domainWhiteList` array to be empty, then all redirect requests will be released by default, which is equivalent to `ctx.unsafeRedirect(url)`.
0 commit comments