errorable-express-middleware
v0.0.2
Published
express middleware for errorable
Downloads
5
Readme
errorable-express
express middleware for errorable
Installation
$ npm install --save errorable-express
API
- res.errors Keeps all errors defined, like res.errors.Success.
- res.errorize/res.restify Generate the json object for the error and insert data if possible
Usage
var errorableExpress = require('errorable-express');
var common = require('errorable-common');
var errorable = require('errorable');
var Generator = errorable.Generator;
var errors = new Generator(common, 'zh-CN').errors;
express.use(errorableExpress(errors));
express.get('/', function indexxx(req, res) {
res.restify(res.errors.Success);
});
express.get('/message', function messagexx(req, res) {
res.restify(res.errors.Success, message);
});
express.get('/unknown', function unknownxx(req, res) {
res.restify();
});
express.get('/errorize', function errorizexx(req, res) {
//restify === errorize
res.errorize();
});
License
MIT © calidion