capishe
v0.0.4
Published
Utilities for building APIs in express.
Downloads
3
Readme
capishe
Helpers and handlers for building jsonp APIs in express
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