r.pipe

HttpEffect route builder based on IxMonad

Importing

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

pipe

r namespace function. Creates pipeable RouteEffect builder.

Type declaration

pipe :: ...Arity<IxBuilder, IxBuilder> -> RouteEffect

r.pipe builder pays attention to the order of applied operators.

const example$ = r.pipe(
  r.matchPath('/'),
  r.matchType('GET'),
  r.use(middleware_1$),
  r.useEffect(req$ => req$.pipe(
    // ...
  )),
  r.use(middleware_2$), // ❌ type error!
);

// or 

const example$ = r.pipe(
  r.matchType('GET'),
  r.matchPath('/'), // ❌ type error!
  r.use(middleware_1$),
  r.use(middleware_2$), 
  r.useEffect(req$ => req$.pipe(
    // ...
  )),
);

Correct order:

  1. <optional> applyMeta

  2. matchPath

  3. matchType

  4. use [...]

  5. useEffect

  6. applyMeta [...]

matchPath

r namespace function. Matches request path for connected HttpEffect.

Type declaration

matchPath :: string -> IxBuilder -> IxBuilder

Parameters

matchType

r namespace function. Matches HTTP method type for connected HttpEffect.

Type declaration

matchType :: HttpMethod -> IxBuilder -> IxBuilder

Parameters

use

r namespace function. Registers HTTP middleware with connected HttpEffect.

Type declaration

use :: HttpMiddlewareEffect -> IxBuilder -> IxBuilder

Parameters

useEffect

r namespace function. Registers HttpEffect.

Type declaration

useEffect :: HttpEffect -> IxBuilder -> IxBuilder

Parameters

applyMeta

r namespace function. Applies metadata to connected HttpEffect.

Type declaration

applyMeta :: RouteMeta -> IxBuilder -> IxBuilder

Parameters

RouteMeta attributes:

Example

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

const example$ = r.pipe(
  r.applyMeta({ continuous: true }),
  r.matchPath('/'),
  r.matchType('GET'),
  r.use(middleware_1$),
  r.use(middleware_2$),
  r.useEffect(req$ => req$.pipe(
    // ...
  )),
  r.applyMeta({ meta_1: /* ... */ }),
  r.applyMeta({ meta_1: /* ... */ }),
);

Last updated