os

observable-server

A wrapper for HTTP server using RxJS

Showing:

Popularity

Downloads/wk

1

GitHub Stars

0

Maintenance

Last Commit

4yrs ago

Contributors

0

Package

Dependencies

4

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Observable Server

Like Express but with observables

Usage

import createServer from 'observable-server'
// OR
const createServer = require('observable-server')

const server = createServer()

server
  .on({ url: '/users', method: 'post' })
  .subscribe(({ request, resposne }) => { /* ... */ })

API

createServer is the only export from this package. It is a function that takes an options object and returns a ServerInterface, both of which are defined below.

  • options: The options for our server
    • port: The port to listen on. Defaults to 5000
    • pre: An HoF that will be given RouteOptions and return an rxjs lettable function to run before each route handler. See ./index.js export for preprocessors that are applied by default.
  • ServerInterface: The interface for our server stream
    • on: A function that, given a RouteOptions shape, returns an observable
      • RouteOptions
        • url: An express-style url to match on
        • method: The HTTP method to listen on or '*' or undefined for all methods
        • Any other values that are expected by a pre for its routeOptions Hof function.

For a full demo, check out ./demo.js or after installing this locally, run npx nodemon demo.js and send requests to the server.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial