Reactive Server
- Allows you to send a stream as input, and return a stream
- You can also return a value, promise or stream
- Client is ~3 kb bundled, built on top of nanosocket. Server is express + uws.
- Allows uploading binary with progress events
Server:
xrs = server = server = server =
- You can also use the signature
(req, res)
if you don't want to return the value. - You can access the underlying
uws
,express
andhttp
instance on theserver
. - For additional options: you pass in
{ port, certs, processor }
instead of just aprocessor
function. Otherwise theport
will be random, and nocerts
will mean you get a HTTP server rather than a HTTPS server. - The input stream can be accessed via
req.on('data')
- The
req
has the following properties:{ id, socket, data, res }
-data
is what the client sent
Client
send =
You can similarly send a value, promise or stream. send
returns a stream of all the server responses. In all cases, you get a sent
event on the stream when it's actually sent. When sending binaries you can also associate some metadata, and get a stream of progress events (this is from the end-to-end tests):
const results = await results === type: 'sent' value: id: '1' type: 'progress' value: received: 1024 total: 2000 type: 'progress' value: received: 2000 total: 2000 type: 'complete' value: 'ack'