-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
otherwise the returned type is never
- Loading branch information
Showing
17 changed files
with
80 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import { type Matcher, type MatchResult, type Method, type QueryMatch, type QueryResult, type QueryStringMatcherInput } from './index.js'; | ||
import type { RegExpMatch, RegExpResult } from './RegExpPathnameMatcher.js'; | ||
import { type Matcher, type MatchResult, type Method, type QueryStringMatch, type QueryStringMatcherInput, type QueryStringResult } from './index.js'; | ||
import type { RegExpPathnameMatch, RegExpPathnameResult } from './RegExpPathnameMatcher.js'; | ||
export interface EndpointMatcherInput { | ||
req: { | ||
url: string; | ||
method: string; | ||
}; | ||
} | ||
export type EndpointMatchResult<R extends RegExpMatch, U extends QueryMatch> = MatchResult<{ | ||
export type EndpointMatchResult<R extends RegExpPathnameMatch, U extends QueryStringMatch> = MatchResult<{ | ||
method: Method; | ||
pathname: RegExpResult<R>; | ||
query: QueryResult<U>; | ||
pathname: RegExpPathnameResult<R>; | ||
query: QueryStringResult<U>; | ||
}>; | ||
/** | ||
* higher order matcher which is combine matching of method | ||
* with regular expression | ||
*/ | ||
export declare class EndpointMatcher<R extends RegExpMatch, P extends EndpointMatcherInput = EndpointMatcherInput, U extends QueryMatch = QueryMatch, QP extends QueryStringMatcherInput = QueryStringMatcherInput> implements Matcher<EndpointMatchResult<R, U>, P> { | ||
export declare class EndpointMatcher<R extends RegExpPathnameMatch, P extends EndpointMatcherInput = EndpointMatcherInput, U extends QueryStringMatch = QueryStringMatch, QP extends QueryStringMatcherInput = QueryStringMatcherInput> implements Matcher<EndpointMatchResult<R, U>, P> { | ||
private readonly matcher; | ||
constructor(methods: Method | Method[], urls: RegExp | string | (RegExp | string)[], params?: { | ||
url?: R; | ||
query?: U; | ||
}); | ||
match(params: EndpointMatcherInput): EndpointMatchResult<R, U>; | ||
} | ||
export declare function endpoint<R extends RegExpMatch, P extends EndpointMatcherInput = EndpointMatcherInput, U extends QueryMatch = QueryMatch, QP extends QueryStringMatcherInput = QueryStringMatcherInput>(...args: ConstructorParameters<typeof EndpointMatcher<R, P, U, QP>>): EndpointMatcher<R, P, U, QP>; | ||
export declare function endpoint<R extends RegExpPathnameMatch, P extends EndpointMatcherInput = EndpointMatcherInput, U extends QueryStringMatch = QueryStringMatch, QP extends QueryStringMatcherInput = QueryStringMatcherInput>(...args: ConstructorParameters<typeof EndpointMatcher<R, P, U, QP>>): EndpointMatcher<R, P, U, QP>; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import type { AnyValidator, Validator } from '../validators.js'; | ||
import type { FirstValidator, ValidatorReturnType } from '../validators.js'; | ||
import type { Matcher } from './Matcher.js'; | ||
import type { MatchResult } from './MatchResult.js'; | ||
export interface QueryStringMatcherInput { | ||
req: { | ||
url: string; | ||
}; | ||
} | ||
export type QueryMatch = Record<string, AnyValidator>; | ||
export type QueryResult<T extends QueryMatch> = { | ||
[P in keyof T]: T[P] extends Validator<string[] | null, infer O> ? O : never; | ||
export type QueryStringMatch = Record<string, FirstValidator<string[] | undefined>>; | ||
export type QueryStringResult<T extends QueryStringMatch> = { | ||
[P in keyof T]: ValidatorReturnType<T[P]>; | ||
}; | ||
export type QueryStringMatchResult<U extends QueryMatch> = MatchResult<{ | ||
query: QueryResult<U>; | ||
export type QueryStringMatchResult<U extends QueryStringMatch> = MatchResult<{ | ||
query: QueryStringResult<U>; | ||
}>; | ||
declare class QueryStringMatcher<U extends QueryMatch, P extends QueryStringMatcherInput> implements Matcher<QueryStringMatchResult<U>, P> { | ||
declare class QueryStringMatcher<U extends QueryStringMatch, P extends QueryStringMatcherInput> implements Matcher<QueryStringMatchResult<U>, P> { | ||
private readonly listConfig; | ||
constructor(config: U); | ||
match: ({ req }: P) => QueryStringMatchResult<U>; | ||
} | ||
export declare function queryString<U extends QueryMatch, P extends QueryStringMatcherInput>(config: U): QueryStringMatcher<U, P>; | ||
export declare function queryString<U extends QueryStringMatch, P extends QueryStringMatcherInput>(config: U): QueryStringMatcher<U, P>; | ||
export {}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import type { AnyValidator, Validator } from '../index.js'; | ||
import type { FirstValidator, ValidatorReturnType } from '../index.js'; | ||
import type { Matcher } from './Matcher.js'; | ||
import type { MatchResult } from './MatchResult.js'; | ||
export interface RegExpPathnameMatcherInput { | ||
req: { | ||
url: string; | ||
}; | ||
} | ||
export type RegExpMatch = Record<string, AnyValidator>; | ||
export type RegExpResult<T extends RegExpMatch> = { | ||
export type RegExpPathnameMatch = Record<string, FirstValidator<string[] | undefined>>; | ||
export type RegExpPathnameResult<T extends RegExpPathnameMatch> = { | ||
url: string; | ||
params: { | ||
[P in keyof T]: T[P] extends Validator<string[] | null, infer O> ? O : never; | ||
[P in keyof T]: ValidatorReturnType<T[P]>; | ||
}; | ||
}; | ||
export type RegExpPathnameMatchResult<R extends RegExpMatch> = MatchResult<{ | ||
pathname: RegExpResult<R>; | ||
export type RegExpPathnameMatchResult<R extends RegExpPathnameMatch> = MatchResult<{ | ||
pathname: RegExpPathnameResult<R>; | ||
}>; | ||
declare class RegExpPathnameMatcher<R extends RegExpMatch, P extends RegExpPathnameMatcherInput = RegExpPathnameMatcherInput> implements Matcher<RegExpPathnameMatchResult<R>, P> { | ||
declare class RegExpPathnameMatcher<R extends RegExpPathnameMatch, P extends RegExpPathnameMatcherInput = RegExpPathnameMatcherInput> implements Matcher<RegExpPathnameMatchResult<R>, P> { | ||
private readonly urls; | ||
private readonly listConfig; | ||
constructor(urls: RegExp[], config?: R); | ||
match({ req }: RegExpPathnameMatcherInput): RegExpPathnameMatchResult<R>; | ||
} | ||
export declare function regExpPathname<R extends RegExpMatch, P extends RegExpPathnameMatcherInput = RegExpPathnameMatcherInput>(urls: RegExp[], config?: R): RegExpPathnameMatcher<R, P>; | ||
export declare function regExpPathname<R extends RegExpPathnameMatch, P extends RegExpPathnameMatcherInput = RegExpPathnameMatcherInput>(urls: RegExp[], config?: R): RegExpPathnameMatcher<R, P>; | ||
export {}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.