LogoLogo
ChangelogGitHubTwitterGitter
v3.x
v3.x
  • Marble.js
  • Getting started
    • Installation
    • Quick setup
  • HTTP
    • Effects
    • Middlewares
    • Routing
    • Errors
    • Output
    • Context
    • Advanced
      • Logging
      • Validation
      • Server Events
      • Streaming
      • Continuous mode
  • Messaging
    • Core concepts
      • Events
      • Effects
    • Microservices
      • AMQP (RabbitMQ)
      • Redis Pub/Sub
    • CQRS
    • WebSockets
  • Testing
    • HTTP routes testing
  • Other
    • How does it glue together?
    • Migration guides
      • Migration from version 2.x
      • Migration from version 1.x
    • API reference
      • core
        • bindTo
        • bindEagerlyTo
        • createEvent
        • createServer
        • combineRoutes
        • createContextToken
        • EffectFactory
        • r.pipe
        • httpListener
        • operator: matchEvent
        • operator: use
        • operator: act
      • messaging
        • eventBus
        • messagingClient
        • createMicroservice
        • reply
      • websockets
        • webSocketListener
        • operator: broadcast
        • operator: mapToServer
      • middleware-multipart
      • middleware-cors
      • middleware-joi
      • middleware-jwt
        • Token signing
      • middleware-io
      • middleware-logger
      • middleware-body
    • Style Guide
    • FAQ
Powered by GitBook
On this page
  • Importing
  • pipe
  • Type declaration
  • matchPath
  • Type declaration
  • Parameters
  • matchType
  • Type declaration
  • Parameters
  • use
  • Type declaration
  • Parameters
  • useEffect
  • Type declaration
  • Parameters
  • applyMeta
  • Type declaration
  • Parameters
  • Example
  1. Other
  2. API reference
  3. core

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

parameter

definition

path

string

matchType

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

Type declaration

matchType :: HttpMethod -> IxBuilder -> IxBuilder

Parameters

parameter

definition

path

HttpMethod

use

r namespace function. Registers HTTP middleware with connected HttpEffect.

Type declaration

use :: HttpMiddlewareEffect -> IxBuilder -> IxBuilder

Parameters

parameter

definition

middleware

HttpMiddlewareEffect

useEffect

r namespace function. Registers HttpEffect.

Type declaration

useEffect :: HttpEffect -> IxBuilder -> IxBuilder

Parameters

parameter

definition

effect

HttpEffect

applyMeta

r namespace function. Applies metadata to connected HttpEffect.

Type declaration

applyMeta :: RouteMeta -> IxBuilder -> IxBuilder

Parameters

parameter

definition

meta

RouteMeta

RouteMeta attributes:

parameter

type

definition

name

<optional> string

route/effect name

continuous

<optional> boolean

overridable

<optional> boolean

if true, the route can be overrode by another route

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: /* ... */ }),
);
PreviousEffectFactoryNexthttpListener

Last updated 5 years ago

enables

continuous mode