Skip to content

Commit bcd898c

Browse files
authored
Merge branch 'master' into ts
2 parents 08d2ced + e96ddb6 commit bcd898c

7 files changed

Lines changed: 69 additions & 20 deletions

File tree

History.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# History
22

3+
## 2018-05-05, Version 2.8.1 @atian25
4+
5+
### Notable changes
6+
7+
* **docs**
8+
* fix missing d.ts
9+
10+
### Commits
11+
12+
* [[`20356bffc`](http://github.com/eggjs/egg/commit/20356bffcf7e99970b44f230a6fc2a8f9547a380)] - feat(d.ts): add createAnonymousContext & runInBackground (#2501) (Hengfei Zhuang <<zhuanghengfei@gmail.com>>)
13+
* [[`c013ef3e6`](http://github.com/eggjs/egg/commit/c013ef3e64e049c6ef48e29d289f6d756b6ca1f7)] - feat(d.ts): add runSchedule & Subscription define (#2504) (Hengfei Zhuang <<zhuanghengfei@gmail.com>>)
14+
315
## 2018-05-03, Version 2.8.0 @dead-horse
416

517
### Notable changes
@@ -23,7 +35,7 @@
2335
* [[`73dac083d`](http://github.com/eggjs/egg/commit/73dac083d2a029f893e9b6737080c921027e308f)] - docs: update wxapp-socket-io project to weapp.socket.io (#2421) (liuguili <<gongzili456@gmail.com>>)
2436
* [[`1ada8e384`](http://github.com/eggjs/egg/commit/1ada8e3848be9f09680d7cac091fb14206df5a11)] - feat(d.ts): add middleware to Application and other ts improvement (#2465) (Axes <<whxaxes@qq.com>>)
2537
* [[`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 |
38+
* [[`f341b9fb8`](http://github.com/eggjs/egg/commit/f341b9fb8bdf36b6280500578e8448c59aec10f1)] - chore: update title and remove unused files (#2433) (TZ |
2739
天猪 <<atian25@qq.com>>)
2840
* [[`a5ab29cbd`](http://github.com/eggjs/egg/commit/a5ab29cbd1de0f5425019085258a496b4bce8b45)] - docs: switch to English document (#2426) (Haoliang Gao <<sakura9515@gmail.com>>)
2941
* [[`4ab7df25f`](http://github.com/eggjs/egg/commit/4ab7df25f152609d494745eac2794b78e66444f0)] - deps: update dependencies, add @types/urllib to autod config (#2423) (Yiyu He <<dead_horse@qq.com>>)

README.zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ $ open http://localhost:7001
6363

6464
## 贡献代码
6565

66-
Please let us know what we can help, check [issues](https://github.com/eggjs/egg/issues) for bug reporting and suggestion.
66+
请告知我们可以为你做些什么,不过在此之前,请检查一下是否有[已经存在的Bug或者意见](https://github.com/eggjs/egg/issues)
6767

68-
If you are a contributor, follow [CONTRIBUTING](CONTRIBUTING.md).
68+
如果你是一个代码贡献者,请参考[代码贡献规范](CONTRIBUTING.md)
6969

7070
## 开源协议
7171

app/extend/context.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const CONTEXT_HTTPCLIENT = Symbol('Context#httpclient');
1313

1414

1515
const proto = module.exports = {
16+
17+
/**
18+
* Get the current visitor's cookies.
19+
*/
1620
get cookies() {
1721
if (!this[COOKIES]) {
1822
this[COOKIES] = new this.app.ContextCookies(this, this.app.keys);

app/extend/request.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ module.exports = {
9595
},
9696

9797
/**
98-
* Request remote IPv4 address
98+
* Get or set the request remote IPv4 address
9999
* @member {String} Request#ip
100+
* @param {String} ip - IPv4 address
100101
* @example
101102
* ```js
102103
* this.request.ip
@@ -115,10 +116,6 @@ module.exports = {
115116
return this._ip;
116117
},
117118

118-
/**
119-
* Set the remote address
120-
* @param {String} ip - IPv4 address
121-
*/
122119
set ip(ip) {
123120
this._ip = ip;
124121
},
@@ -178,7 +175,7 @@ module.exports = {
178175
},
179176

180177
/**
181-
* get params pass by querystring, all value are String type.
178+
* get params pass by querystring, all values are of string type.
182179
* @member {Object} Request#query
183180
* @example
184181
* ```js

app/extend/response.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@ const isJSON = require('koa-is-json');
55
const REAL_STATUS = Symbol('Context#realStatus');
66

77
module.exports = {
8-
set length(n) {
8+
9+
/**
10+
* Get or set the length of content.
11+
*
12+
* For Get: If the original content length is null or undefined, it will read out
13+
* the body's content length as the return value.
14+
*
15+
* @member {Number} Response#type
16+
* @param {Number} len The content-length to be set.
17+
*/
18+
set length(len) {
919
// copy from koa
1020
// change header name to lower case
11-
this.set('content-length', n);
21+
this.set('content-length', len);
1222
},
1323

1424
get length() {
@@ -27,6 +37,17 @@ module.exports = {
2737
return parseInt(len, 10);
2838
},
2939

40+
/**
41+
* Get or set the content-type.
42+
*
43+
* For Set: If type is null or undefined, this property will be removed.
44+
*
45+
* For Get: If the value is null or undefined, an empty string will be returned;
46+
* if you have multiple values seperated by `;`, ONLY the first one will be returned.
47+
*
48+
* @member {String} Response#type
49+
* @param {String} type The content-type to be set.
50+
*/
3051
set type(type) {
3152
// copy from koa
3253
// change header name to lower case
@@ -46,13 +67,14 @@ module.exports = {
4667
},
4768

4869
/**
49-
* read response real status code.
70+
* Get or set a real status code.
5071
*
5172
* e.g.: Using 302 status redirect to the global error page
5273
* instead of show current 500 status page.
5374
* And access log should save 500 not 302,
5475
* then the `realStatus` can help us find out the real status code.
55-
* @member {Number} Context#realStatus
76+
* @member {Number} Response#realStatus
77+
* @param {Number} status The status code to be set.
5678
*/
5779
get realStatus() {
5880
if (this[REAL_STATUS]) {
@@ -61,12 +83,6 @@ module.exports = {
6183
return this.status;
6284
},
6385

64-
/**
65-
* set response real status code.
66-
*
67-
* @member {Void} Response#realStatus
68-
* @param {Number} status the real status code
69-
*/
7086
set realStatus(status) {
7187
this[REAL_STATUS] = status;
7288
},

index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ declare module 'egg' {
525525
*/
526526
beforeStart(scrope: () => void): void;
527527

528+
runSchedule(schedulePath: string): Promise<any>;
529+
528530
/**
529531
* Close all, it wil close
530532
* - callbacks registered by beforeClose
@@ -607,6 +609,22 @@ declare module 'egg' {
607609
Controller: Controller;
608610

609611
middleware: KoaApplication.Middleware[] & IMiddleware;
612+
613+
/**
614+
* Create an anonymous context, the context isn't request level, so the request is mocked.
615+
* then you can use context level API like `ctx.service`
616+
* @member {String} Application#createAnonymousContext
617+
* @param {Request} req - if you want to mock request like querystring, you can pass an object to this function.
618+
* @return {Context} context
619+
*/
620+
createAnonymousContext(req?: Request): Context;
621+
622+
/**
623+
* Run async function in the background
624+
* @see Context#runInBackground
625+
* @param {Function} scope - the first args is an anonymous ctx
626+
*/
627+
runInBackground(scope: (ctx: Context) => void): void;
610628
}
611629

612630
export interface FileStream extends Readable { // tslint:disable-line
@@ -861,6 +879,8 @@ declare module 'egg' {
861879

862880
export class Service extends BaseContextClass { }
863881

882+
export class Subscription extends BaseContextClass { }
883+
864884
/**
865885
* The empty interface `IService` is a placeholder, for egg
866886
* to auto injection service to ctx.service

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "egg",
3-
"version": "2.8.0",
3+
"version": "2.8.1",
44
"description": "A web framework's framework for Node.js",
55
"keywords": [
66
"web",

0 commit comments

Comments
 (0)