Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3f183e

Browse files
Maledongatian25
authored andcommitted
fix (typescript): Add missing 'ignore','match' (eggjs#3010)
1 parent d8c865a commit e3f183e

6 files changed

Lines changed: 17 additions & 8 deletions

File tree

docs/source/en/basics/middleware.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ module.exports = {
230230
```
231231
match and ignore support various types of configuration ways:
232232

233-
1. String: when string, it sets the prefix of a url path, and all urls starting with this prefix will be matched.
233+
1. String: when string, it sets the prefix of a url path, and all urls starting with this prefix will be matched. A string array is also accepted.
234234
2. Regular expression: when regular expression, all urls satisfy this regular expression will be matched.
235235
3. Function: when function, the request context will be passed to it and what it returns(true/false) determines whether the request is matched or not.
236236

@@ -245,3 +245,4 @@ module.exports = {
245245
},
246246
};
247247
```
248+
For more configs about `match` and `ignore`, please refer to [egg-path-matching](https://github.com/eggjs/egg-path-matching).

docs/source/zh-cn/basics/middleware.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ module.exports = {
232232
match 和 ignore 支持多种类型的配置方式
233233

234234
1. 字符串:当参数为字符串类型时,配置的是一个 url 的路径前缀,所有以配置的字符串作为前缀的 url 都会匹配上。
235+
当然,你也可以直接使用字符串数组。
235236
2. 正则:当参数为正则时,直接匹配满足正则验证的 url 的路径。
236237
3. 函数:当参数为一个函数时,会将请求上下文传递给这个函数,最终取函数返回的结果(ture/false)来判断是否匹配。
237238

@@ -246,3 +247,5 @@ module.exports = {
246247
},
247248
};
248249
```
250+
有关更多的 match 和 ignore 配置情况,详见
251+
[egg-path-matching](https://github.com/eggjs/egg-path-matching).

index.d.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ declare module 'egg' {
209209
root: string; // baseDir when local and unittest, HOME when other environment
210210
}
211211

212+
type IgnoreItem = string | RegExp | ((ctx: Context) => boolean);
213+
type IgnoreOrMatch = IgnoreItem | IgnoreItem[];
214+
212215
export interface EggAppConfig {
213216
workerStartTimeout: number;
214217
baseDir: string;
@@ -236,17 +239,19 @@ declare module 'egg' {
236239
encoding: string;
237240
formLimit: string;
238241
jsonLimit: string;
239-
strict: true;
242+
strict: boolean;
240243
queryString: {
241244
arrayLimit: number;
242245
depth: number;
243246
parameterLimit: number;
244247
};
248+
ignore: IgnoreOrMatch;
249+
match: IgnoreOrMatch;
245250
enableTypes: string[];
246251
extendTypes: {
247-
json?: string[];
248-
form?: string[];
249-
text?: string[];
252+
json: string[];
253+
form: string[];
254+
text: string[];
250255
};
251256
};
252257

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"egg-alinode": "^1.0.3",
6464
"egg-bin": "^4.8.5",
6565
"egg-doctools": "^2.4.0",
66-
"egg-mock": "^3.20.0",
66+
"egg-mock": "^3.20.1",
6767
"egg-plugin-puml": "^2.4.0",
6868
"egg-tracer": "^1.1.0",
6969
"egg-view-nunjucks": "^2.2.0",

test/fixtures/apps/app-ts/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es6",
3+
"target": "es2015",
44
"baseUrl": ".",
55
"paths": {
66
"egg": ["../../../../index"]

test/lib/agent.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('test/lib/agent.test.js', () => {
2727
setTimeout(() => {
2828
const body = fs.readFileSync(path.join(baseDir, 'logs/agent-throw/common-error.log'), 'utf8');
2929
assert(body.includes('nodejs.unhandledExceptionError: agent error'));
30-
app.notExpect(/nodejs.AgentWorkerDiedError/);
30+
app.notExpect('stderr', /nodejs.AgentWorkerDiedError/);
3131
done();
3232
}, 1000);
3333
});

0 commit comments

Comments
 (0)