rest-npm

A RESTful API wrapper for the npm module (useful for mobile clients)

npm install rest-npm

rest-npm takes two parameters. A port to run on, and an object that defines what commands the API will accept as well as the number of arguments each one requires.

var restNpm = require('rest-npm')
 
// Configure with port and valid commands 
restNpm.start(3000, {
  // view command accepts between 1 and 5 params 
  view: [ 1, 5 ],
  
  // search command accepts 1 and only 1 param 
  search: 1
});

The query structure is very simple. I wanted to mirror the npm cli interface as close as possible so the structure is very generic.

# Basic structure
/<COMMAND>?p=<PARAM_1>&p=<PARAM_2>&p=<PARAM_3>
 
# Sample search query
#  npm search blog
/search?p=blog
 
# View module name, description and version
#  npm view express name description version
/view?p=express&p=name&p=description&p=version
  • Write unit tests
  • Better error handling