httpListener

Starting point of every Marble.js application. It includes definitions of all middlewares and API effects.

Importing

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

Type declaration

httpListener :: HttpListenerConfig -> (IncomingMessage, OutgoingMessage) -> void;

Parameters

parameter

definition

config

HttpListenerConfig

req

Node.js Http.IncomingMessage

res

Node.js Http.OutgoingMessage

HttpListenerConfig

parameter

definition

effects

Array<RouteEffect | RouteEffectGroup>

middlewares

<optional> Array<HttpMiddlewareEffect>

error$

<optional> HttpErrorEffect

Returns

Besides the default http server handler, the httpListener returns also an configuration object.

parameter

definitoin

routing

Array<RoutingItem>

injector

StaticInjector

Example

http.listener
import { httpListener } from '@marblejs/core';
import { bodyParser$ } from '@marblejs/middleware-body';
import { logger$ } from '@marblejs/middleware-logger';
import { api$ } from './api';

const middlewares = [
  logger$(),
  bodyParser$(),
];

const effects = [
  api$,
];

export default httpListener({ middlewares, effects });

Last updated