Getting started

Installation

Marble.js requires node v8.0 or higher:

$ npm i @marblejs/core rxjs

or if you are a hipster:

$ yarn add @marblejs/core rxjs

Bootstrapping

The bootstrapping consists of two very simple steps: HTTP handler definition and HTTP server configuration.

httpListener is the starting point of every Marble.js application. It includes definitions of all middlewares and API effects.

app.ts
const middlewares = [
  logger$,
  bodyParser$,
];

const effects = [
  endpoint1$,
  endpoint2$,
  ...
];

export const app = httpListener({ middlewares, effects });

Because Marble.js is built on top of Node.js platform and doesn't create any abstractions for server bootstrapping - all you need to do is to call createServer with initialized app and then start listening to given port and hostname.

server.ts
import { app } from './app.ts';

const httpServer = http
  .createServer(app)
  .listen(PORT, HOSTNAME);

Last updated