0.0.7 • Published 5 years ago

red-panda-web v0.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Red Panda Web

CI Status NPM Version

A functional web server written with rxjs.

Documentation

API Docs can be found here.

Quick Start

Install red-panda-web:

$ npm install --save-prod red-panda-web

Add the following to a file:

import { RedPandaWeb, handleErrorsAndSend, get, produce, routes } from "red-panda-web";

function main() {
  const app = new RedPandaWeb();

  app.requestSource$
    .pipe(
      routes(
        get("/", o$ =>
          o$.pipe(
            produce(r => {
              r.headers["Content-Type"] = "text/plain";
              r.status = 200;
              r.body = Buffer.from("Hello world!\n");
            })
          )
        )
      ),
      handleErrorsAndSend()
    )
    .subscribe();

  app.listenAndServe(s => console.log("Listening at:", s.address()));
}

if (require.main) {
  main();
}

Run the script, and then call:

$ curl localhost:3000
# Outputs >>> Hello world!

Developing

CommandDescription
npm run packageClean lib/, lint source, run tests, compile to lib.
npm run test:watchRun test suite in --watch mode.
npm testRun test suite.
0.0.5

5 years ago

0.0.4

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago