capishe

0.0.4 • Public • Published

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

/capishe/

    Package Sidebar

    Install

    npm i capishe

    Weekly Downloads

    4

    Version

    0.0.4

    License

    MIT

    Last publish

    Collaborators

    • tgvashworth