combineRoutes

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

Importing

import { combineRoutes } from '@marblejs/core';

Type declaration

combineRoutes :: (string, RouteCombinerConfig) -> RouteEffectGroup
combineRoutes :: (string, (RouteEffect | RouteEffectGroup)[]) -> RouteEffectGroup

Parameters

RouteCombinerConfig

Returns

Factorized RouteEffectGroup object.

Example

import { combineRoutes } from '@marblejs/core';
import { authorize$ } from 'auth.middleware';

// const getUsers$ = ...
// const postUser$ = ...

export const user$ = combineRoutes('/user', {
  middlewares: [authorize$],
  effects: [getUsers$, postUser$],
});
import { combineRoutes } from '@marblejs/core';
import { user$ } from './user.effects';

// const root$ = ...
// const notFound$ = ...

export const api$ = combineRoutes('/api/v1', [
  root$,
  user$,
  notFound$,
]);

Last updated