capishe

Utilities for building APIs in express.

npm install capishe
16 downloads in the last month

capishe

Helpers and handlers for building jsonp APIs in express

build status

example

The following examples assume this:

// express 'app' available
var capishe = require('capishe');

noops

Send a noop:

// res.jsonp({}) is sent
app.get('/', capishe.noop());

With custom data:

// res.jsonp({ hello: 'world' }) is sent
app.get('/', capishe.noop({
  hello: 'world'
}));

database

Send data from db with appropriate 200, 500 or 404:

app.get('/', function (req, res) {
  YourModel
    .find()
    .exec(capishe.db(req, res));
});

checks

Check for the presence of a particular URL parameter:

// calls next() becuase present
app.get('/:testParam',
        capishe.check.params('testParam'),
        capishe.noop());

400 errors becuase of missing parameter

app.get('/',
        capishe.check.params('testParam'),
        capishe.noop());

install

npm install capishe

license

MIT

npm loves you