|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import {Awaitable, Collection, Either, ErrorWithContext, Maybe, Pipeline, PrefixTypeArray, right} from '../../util'
|
|
|
|
|
import {Awaitable, Collection, Either, ErrorWithContext, Maybe, Pipeline, SuffixTypeArray, right} from '../../util'
|
|
|
|
|
import {ResponseFactory} from '../response/ResponseFactory'
|
|
|
|
|
import {HTTPMethod, Request} from '../lifecycle/Request'
|
|
|
|
|
import {constructable, Constructable, Container, Instantiable, isInstantiableOf, TypedDependencyKey} from '../../di'
|
|
|
|
@ -317,8 +317,8 @@ export class Route<TReturn extends ResponseObject, THandlerParams extends unknow
|
|
|
|
|
public parameterMiddleware<T, THandlerArgs extends any[] = []>(
|
|
|
|
|
handler: ParameterProvidingMiddleware<T> | Instantiable<ParameterMiddleware<T, THandlerArgs>>,
|
|
|
|
|
...handlerArgs: THandlerArgs
|
|
|
|
|
): Route<TReturn, PrefixTypeArray<T, THandlerParams>> {
|
|
|
|
|
const route = new Route<TReturn, PrefixTypeArray<T, THandlerParams>>(
|
|
|
|
|
): Route<TReturn, SuffixTypeArray<THandlerParams, T>> {
|
|
|
|
|
const route = new Route<TReturn, SuffixTypeArray<THandlerParams, T>>(
|
|
|
|
|
this.method,
|
|
|
|
|
this.route,
|
|
|
|
|
)
|
|
|
|
@ -409,7 +409,7 @@ export class Route<TReturn extends ResponseObject, THandlerParams extends unknow
|
|
|
|
|
return this
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public input<T>(validator: ValidatorFactory<T>): Route<TReturn, PrefixTypeArray<Valid<T>, THandlerParams>> {
|
|
|
|
|
public input<T>(validator: ValidatorFactory<T>): Route<TReturn, SuffixTypeArray<THandlerParams, Valid<T>>> {
|
|
|
|
|
if ( !(validator instanceof Validator) ) {
|
|
|
|
|
validator = validator()
|
|
|
|
|
}
|
|
|
|
@ -422,7 +422,7 @@ export class Route<TReturn extends ResponseObject, THandlerParams extends unknow
|
|
|
|
|
return this.parameterMiddleware(validateMiddleware(validator))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public passingRequest(): Route<TReturn, PrefixTypeArray<Request, THandlerParams>> {
|
|
|
|
|
public passingRequest(): Route<TReturn, SuffixTypeArray<THandlerParams, Request>> {
|
|
|
|
|
return this.parameterMiddleware(request => right(request))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|