Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Node, NetworkHub } from 'smoke-node'
- async function main() {
- const node = new Node({ hub: new NetworkHub('ws://tachy0n.com:5001/') })
- // print local information about your local node
- console.log('local address: ', await node.address())
- console.log('local configuration', JSON.stringify(await node.hub.configuration(), null, 2))
- // create a simple rest server.
- const server = node.rest.createServer()
- server.get('/', (req, res) => {
- console.log('server has request', req)
- res.send('hello world')
- })
- server.listen(80)
- // fetch it
- const remote_address = 'x.0.0.0'
- const data = await node_b.rest.fetch(`rest://${remote_address}`).then(res => res.text())
- console.log(data)
- }
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement