Building with NodeJS¶
Most of the APIs exposed (Buckets daemon, Threads daemons, and the Hub) do so over WebSockets. WebSockets are baked into every major browser but don't come with NodeJS by default, so we'll have to add them.
Adding WebSockets to NodeJS¶
The easiest solution to make all libraries compatible is to add WebSockets to the global namespace.
We'll use the
isomorphic-ws library to add WebSockets to our Node app.
npm install --save isomorphic-ws ws
You can now just add WebSockets to the global namespace in your apps. Add this to the first line in your
ts files, usually
main.js or similar.
;(global as any).WebSocket = require('isomorphic-ws')
;global.WebSocket = require('isomorphic-ws')
That's it. Now start building with the full suite of Textile tools.
Check out the app-building tutorials for ideas.