Error response enhancements, CoreID auth client backend
This commit is contained in:
@@ -72,12 +72,16 @@ export class Route<TReturn extends ResponseObject, THandlerParams extends unknow
|
||||
for ( const group of stack ) {
|
||||
route.prepend(group.prefix)
|
||||
group.getPreflight()
|
||||
.each(def => route.preflight.prepend(def))
|
||||
.each(def => route.preflight.prepend(
|
||||
request => request.make<Middleware>(def, request).apply(),
|
||||
))
|
||||
}
|
||||
|
||||
for ( const group of this.compiledGroupStack ) {
|
||||
group.getPostflight()
|
||||
.each(def => route.postflight.push(def))
|
||||
.each(def => route.postflight.push(
|
||||
request => request.make<Middleware>(def, request).apply(),
|
||||
))
|
||||
}
|
||||
|
||||
// Add the global pre- and post- middleware
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import {Collection, ErrorWithContext} from '../../util'
|
||||
import {AppClass} from '../../lifecycle/AppClass'
|
||||
import {ResolvedRouteHandler} from './Route'
|
||||
import {Container} from '../../di'
|
||||
import {Container, Instantiable} from '../../di'
|
||||
import {Logging} from '../../service/Logging'
|
||||
import {Middleware} from './Middleware'
|
||||
|
||||
/**
|
||||
* Class that defines a group of Routes in the application, with a prefix.
|
||||
*/
|
||||
export class RouteGroup extends AppClass {
|
||||
protected preflight: Collection<ResolvedRouteHandler> = new Collection<ResolvedRouteHandler>()
|
||||
protected preflight: Collection<Instantiable<Middleware>> = new Collection()
|
||||
|
||||
protected postflight: Collection<ResolvedRouteHandler> = new Collection<ResolvedRouteHandler>()
|
||||
protected postflight: Collection<Instantiable<Middleware>> = new Collection()
|
||||
|
||||
/**
|
||||
* The current set of nested groups. This is used when compiling route groups.
|
||||
@@ -87,22 +87,22 @@ export class RouteGroup extends AppClass {
|
||||
}
|
||||
|
||||
/** Register the given middleware to be applied before all routes in this group. */
|
||||
pre(middleware: ResolvedRouteHandler): this {
|
||||
pre(middleware: Instantiable<Middleware>): this {
|
||||
this.preflight.push(middleware)
|
||||
return this
|
||||
}
|
||||
|
||||
/** Register the given middleware to be applied after all routes in this group. */
|
||||
post(middleware: ResolvedRouteHandler): this {
|
||||
post(middleware: Instantiable<Middleware>): this {
|
||||
this.postflight.push(middleware)
|
||||
return this
|
||||
}
|
||||
|
||||
getPreflight(): Collection<ResolvedRouteHandler> {
|
||||
getPreflight(): Collection<Instantiable<Middleware>> {
|
||||
return this.preflight
|
||||
}
|
||||
|
||||
getPostflight(): Collection<ResolvedRouteHandler> {
|
||||
getPostflight(): Collection<Instantiable<Middleware>> {
|
||||
return this.postflight
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user