LogoLogo
ChangelogGitHubTwitterGitter
v2.x
v2.x
  • Introduction
  • Overview
    • Getting started
    • Effects
    • Routing
    • Middlewares
    • Error handling
    • How does it glue​ together?
  • Advanced
    • Context
    • Server events
    • Validation
    • Streaming
    • Output interceptor
  • WebSockets
    • Getting started
    • Effects
    • Middlewares
    • Error handling
    • Connections handling
  • API Reference
    • core
      • bindTo
      • createServer
      • combineRoutes
      • createContextToken
      • EffectFactory
      • r.pipe
      • httpListener
      • operator: matchEvent
      • operator: use
    • websockets
      • webSocketListener
      • operator: broadcast
      • operator: mapToServer
    • middleware-body
    • middleware-logger
    • middleware-io
    • middleware-jwt
      • Token signing
    • middleware-joi
    • middleware-cors
    • middleware-multipart
  • Other
    • Migration from version 1.x
    • Changelog
    • FAQ
Powered by GitBook
On this page
  • Importing
  • + matchPath
  • Type declaration
  • Parameters
  • Returns
  • + matchType
  • Type declaration
  • Parameters
  • Returns
  • + use
  • Type declaration
  • Parameters
  • Returns
  • Example
  1. API Reference
  2. core

EffectFactory

Set of factory functions for building router Effect.

Importing

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

+ matchPath

EffectFactory namespace function. Matches request path for connected Effect.

Type declaration

matchPath :: string -> matchType

Parameters

parameter

definition

path

string

Returns

EffectFactory matchType function

+ matchType

EffectFactory namespace function. Matches HTTP method type for connected Effect.

Type declaration

matchType :: HttpMethod -> use

Parameters

parameter

definition

type

HttpMethod = 'POST | 'PUT' | 'PATCH' | 'GET' | 'HEAD' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | '*'

Returns

EffectFactory use function

+ use

EffectFactory namespace function. Connects Effect with path and HTTP method type.

Type declaration

use :: HttpEffect -> RouteEffect

Parameters

parameter

definition

effect

HttpEffect function

Returns

Factorized RouteEffect object.

Example

root.effect.ts
import { EffectFactory } from '@marblejs/core';

export const root$ = EffectFactory
  .matchPath('/')
  .matchType('GET')
  .use(req$ => req$.pipe(
    mapTo({ body: `Hello, world! 👻` })
  ));

PreviouscreateContextTokenNextr.pipe

Last updated 6 years ago