import { HttpMiddlewareEffect } from '../effects/http.effects.interface' ; import { RouteCombinerConfig , RouteEffectGroup , RouteEffect , ErrorSubject } from './http.router.interface' ; import { isRouteCombinerConfig , decorateMiddleware } from './http.router.helpers' ; export function combineRoutes ( path , config ) ; export function combineRoutes ( path , effects ) ; export function combineRoutes ( path , configOrEffects ) { return { path , effects : isRouteCombinerConfig ( configOrEffects ) ? configOrEffects . effects : configOrEffects , middlewares : isRouteCombinerConfig ( configOrEffects ) ? ( configOrEffects . middlewares || [ ] ) : [ ] , } ; } export const combineRouteMiddlewares = ( decorate , errorSubject ) => ( ... middlewares ) : HttpMiddlewareEffect => ( input$ , ctx ) => middlewares . reduce ( ( i$ , middleware ) => middleware ( decorate ? decorateMiddleware ( i$ , errorSubject ) : i$ , ctx ) , decorate ? decorateMiddleware ( input$ , errorSubject ) : input$ ) ;