observable-server
v0.2.0
Published
> Like Express but with observables
Downloads
7
Maintainers
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 serverport
: The port to listen onpre
: An HoF that will be givenRouteOptions
and return an rxjslettable
function to run before each route handler
ServerInterface
: The interface for our server streamon
: A function that, given aRouteOptions
shape, returns an observableRouteOptions
url
: An express-style url to match onmethod
: The HTTP method to listen on or'*'
orundefined
for all methods- Any other values that are expected by a
pre
for itsrouteOptions
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.