RFC: Node bindings for http & general bindings for any stream based libraries

interop

#1

Hey Everyone,

I am looking for feedback for the node binding libraries we have been building (primarily to learn reason) https://github.com/ConduitVC/reasonml/tree/master/packages/bs-node-ext .

Part of what makes typescript and flow bindings fairly easy to write for node is the node bindings which provide things like stream for use in other bindings. This is my attempt to make a reusable set of bindings that are both useful for interacting with core node modules like http but also other bindings which use things like streams.

The bindings use a combination of modules and classical inheritance so for instance you can use the stream module on an incoming http request. The idea here is to use a class type which inherits from stream so the stream module can operate on that type and any other type which has inherited from readable/writable/duplex/transform streams.

Let me know what you think and if this could potentially be useful! In the best case I would like to see the node bindings upstreamed to bs-node .


#2

Thanks for getting node streams going @lightsofapollo

To comment directly on the bindings you currently have in the repo, I see you’ve been using [@bs.send.pipe: t]. Now that we have the pipe first operator, |., it would be better to change the Api to use [@bs.send]. AFAIK @bs.send.pipe is likely to be deprecated or at least discouraged in future versions of bucklescript.

Another comment that I’d like to make as someone who has been thinking a little about the stream bindings is that node’s stream design is not very user friendly. It would be great to be able to point to our bindings and say “Look! It’s even easier to use than node!”. Adding naïve bindings solves an immediate problem but is rarely idiomatic nor as safe as I would personally like. What I would love to see is a node stream compatible api which has an api like bs-most.