Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fling

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fling

JSON Fling is a simple JSON-RPC framework for NodeJS with built-in permissions and support for different transports.

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

json-fling

JSON Fling is a simple JSON-RPC framework for NodeJS with built-in permissions and support for different transports.

Conforms to JSON RPC 2.0 Specification (http://www.jsonrpc.org/specification)

Example

Server

  // create express server the normal way
  var express = require( 'express' );
  var app = express();

  // setup fling instance before you start the web service
  var fling = require( 'fling' );
  var transport = new fling.transports.receivers.Express( {
    express: app,
    url: '/rpc'
  } );
  var receiver = new fling.Receiver( {
    baseDir: __dirname + '/lib/publicRpc' // this takes an absolute path
  } );

  receiver.addTransport( transport );

  // start the web service
  app.listen( 8080 );

Server RPC Module: /lib/publicRpc/a/path/to/a/node/module.js

  module.exports.action = function( request, done ) {
    done( 200, {
      some: 'response',
      for:  [ 'you' ]
    } );
  };

Client

  var request = require( 'request' );

  request( {
      url: 'http://somehost:8080/rpc',
      json: {
        jsonrpc: '2.0',
        id:      100,
        method:  'a.path.to.a.node.module.action',
        params:  {
          your: 'params',
          here: []
        }
      },
      method: 'POST'
    },
    function( err, response, body ) {

      console.log( body );

      // outputs
      // {
      //   jsonrpc: '2.0',
      //   id:      100,
      //   result:  {
      //     some: 'response',
      //     for:  [ 'you' ]
      //   }
      // }

  } );

Coming Soon

More receiver transports: TCP Socket, in-process, and more Client transports to make an RPC call into a fling server

Keywords

FAQs

Package last updated on 11 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc