|
1 | 1 | import { |
2 | | - IncomingMessage, ServerResponse, |
| 2 | + IncomingMessage, |
| 3 | + ServerResponse, |
3 | 4 | } from 'http' |
4 | 5 | import { Matcher } from './Matcher' |
5 | 6 | import { MatchResult } from './MatchResult' |
6 | 7 | import { |
7 | | - Method, MethodMatchResult, MethodMatcher, |
| 8 | + Method, |
| 9 | + MethodMatchResult, |
| 10 | + MethodMatcher, |
8 | 11 | } from './MethodMatcher' |
9 | 12 | import { AndMatcher } from './AndMatcher' |
10 | 13 | import { |
11 | | - RegExpUrlMatchResult, RegExpUrlMatcher, |
| 14 | + RegExpExecGroupArray, |
| 15 | + RegExpUrlMatchResult, |
| 16 | + RegExpUrlMatcher, |
12 | 17 | } from './RegExpUrlMatcher' |
13 | 18 |
|
14 | 19 | // waiting for |
15 | 20 | // https://github.com/microsoft/TypeScript/issues/10571 |
16 | 21 | // https://github.com/microsoft/TypeScript/pull/26349 |
17 | 22 | // to resolve http method |
18 | 23 |
|
19 | | -export type EndpointMatchResult<R extends Partial<RegExpExecArray>> = |
| 24 | +export type EndpointMatchResult<R extends object> = |
20 | 25 | MatchResult<{ |
21 | 26 | method: Method |
22 | | - match: RegExpExecArray & R |
| 27 | + match: RegExpExecGroupArray<R> |
23 | 28 | }> |
24 | 29 |
|
25 | 30 | /** |
26 | 31 | * higher order matcher which is combine matching of method |
27 | 32 | * with regular expression |
28 | 33 | */ |
29 | | -export class EndpointMatcher<R extends Partial<RegExpExecArray>> |
| 34 | +export class EndpointMatcher<R extends object> |
30 | 35 | implements Matcher<EndpointMatchResult<R>> { |
31 | 36 | private readonly matcher: AndMatcher<MethodMatchResult<[Method]>, RegExpUrlMatchResult<R>> |
32 | 37 | constructor(method: Method, url: RegExp) { |
33 | 38 | this.matcher = new AndMatcher([ |
34 | 39 | new MethodMatcher([method]), |
35 | | - new RegExpUrlMatcher([url]), |
| 40 | + new RegExpUrlMatcher<R>([url]), |
36 | 41 | ]) |
37 | 42 | } |
38 | 43 |
|
|
0 commit comments