combineRoutes
Combines routing for different Effects, prefixed with path passed as a first argument.

Importing

1
import { combineRoutes } from '@marblejs/http';
Copied!

Type declaration

1
combineRoutes :: (string, RouteCombinerConfig) -> RouteEffectGroup
2
combineRoutes :: (string, (RouteEffect | RouteEffectGroup)[]) -> RouteEffectGroup
Copied!

Parameters

parameter
definition
path
string
configOrEffects
RouteCombinerConfig | Array<RouteEffect | RouteEffectGroup>

RouteCombinerConfig

parameter
definition
effects
Array<RouteEffect | RouteEffectGroup>
middlewares
<optional> Array<HttpMiddlewareEffect>

Returns

Factorized RouteEffectGroup object.

Example

user.effects.ts
1
import { combineRoutes } from '@marblejs/http';
2
import { authorize$ } from 'auth.middleware';
3
4
// const getUsers$ = ...
5
// const postUser$ = ...
6
7
export const user$ = combineRoutes('/user', {
8
middlewares: [authorize$],
9
effects: [getUsers$, postUser$],
10
});
Copied!
api.effects.ts
1
import { combineRoutes } from '@marblejs/http';
2
import { user$ } from './user.effects';
3
4
// const root$ = ...
5
// const notFound$ = ...
6
7
export const api$ = combineRoutes('/api/v1', [
8
root$,
9
user$,
10
notFound$,
11
]);
Copied!
Last modified 7mo ago