Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

muxrpc-validation

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

muxrpc-validation

Validation library for muxrpc apis

latest
Source
npmnpm
Version
3.0.2
Version published
Weekly downloads
273
-18.51%
Maintainers
2
Weekly downloads
 
Created
Source

muxrpc validation

Validation library for muxrpc apis.

// create validator library
var valid = require('muxrpc-validation')({
  queryOpts: function (v) {
    if (v.reverse && typeof v.reverse != 'boolean')
      return new TypeError('opts.reverse must be a bool')
  }
})

// api manifest
var manifest = {
  usage: 'sync',
  get:   'async',
  add:   'async',
  list:  'source'
}

// api definition - wrap the functions in the validators
var api = {
  usage:   valid.sync(usage, 'string|boolean'), // multiple types
  get:     valid.async(get, 'string'),
  add:     valid.async(add, ['string'], ['string', 'object']), // multiple signatures
  put:     valid.async(add, {cbOptional: true}, 'string'), // async method works without a cb
  list:    valid.source(list, 'queryOpts?') // optional param
}

function usage (cmd) {
  // ...
}
function get (key, cb) {
  // ...
}
function add (key, value, cb) {
  if (typeof value == 'function') {
    // handle (value, cb)
    value = key
    key = value.key
    cb = value
  }
  // ...
}
function list (opts) {
  opts = opts || {}
  // ...
}

Keywords

muxrpc

FAQs

Package last updated on 26 May 2019

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