1.0.2 • Published 6 years ago

bridle v1.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

Bridle: Black magic Javascript RPC

Version npm Linux Build Coverage Status Known Vulnerabilities License

Installation

npm install --save bridle

Bridle allows exporting functions from a Node.js server and then calling them natively from a client (both Node and browsers are supported).

Remote functions will be ran on the server, with communication occurring using WebSocket transport. Local functions will be ran natively on the client as is.

Note: This project exists because it can, not because it should. The author takes no responsibility for any [mis]use.

Usage

Server:

const Bridle = require('bridle');

new Bridle.Server({
    port: 7777,
    localFunctions: {
        foo: () => {
            console.log('bar');
        }
    },
    remoteFunctions: {
        hello: (name) => 'Hello ' + name
    }
});

Client:

import {Client} from 'bridle';

const rpc = new Client();

rpc.connect('ws://localhost:7777')

    .then(functions => {

        functions.foo();

        functions.hello('world!').then(result => {
            console.log(result);
        }).catch(error => {
            console.log(error);
        });
    });

Output:

$ bar
$ Hello world!

Support

Tested in Node.js v6.10.0, Chrome 63

License

ISC

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago