A RESTful API wrapper for the npm module (useful for mobile clients)
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
app.js
package.json

README.md

Installation

npm install rest-npm

Setup

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
});

Query Structure

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

To-Do

  • Write unit tests
  • Better error handling