-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
otherwise the returned type is never
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* converts Record<K, V> type to [K, V][]. | ||
* Useful for usage with Object.entries() | ||
*/ | ||
export type ObjectToArray<T> = T extends { | ||
[s: keyof any]: infer V; | ||
} ? [keyof T, V][] : never; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
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.
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.