Integration with Sailsjs

in config/http.js


    //Create a new middleware function
    errorable: function(req, res, next) {
      var errorableExpress = require('errorable-express');   //the errorable 
middleware for express
      var common = require('errorable-common');   //the errorable middleware 
for express
      var errorable = require('errorable');      //the errorable library
      var Generator = errorable.Generator;       //Get the generator
      var errors = new Generator(common, 'zh-CN').errors;    //Generate the 
errors
      var callback = errorableExpress(errors);
      callback(req, res, next);
    },

    //Added it to the order array
    order: [
    ...
    'errorable',
    ...
    ]



在 2016年2月21日星期日 UTC+8下午6:32:17,李白字一日写道:
>
> hi, all
>
> Errorable is ready for integration with expressjs.
>
> Errorable is a try to solve problems in defining, migrating, exchanging of 
> errors between projects or companies .
>
> 1. Errorable can be easily defined according to very simple rules.
> 2. Errorable can be easily expand to more than one languaes
> 3. Errorable can be easily customized to your own needs and can easily get 
> what is predefined.
>
> the errorable project is here:
> https://github.com/calidion/errorable
>
> currently available errors are:
> 1. http errors  
> https://github.com/Errorable/http
> 2.  common errors
> https://github.com/Errorable/common
>
>
> the expressjs middleware is here:
> https://github.com/Errorable/express-middleware
>
>
> the following code shows how it works.
>
> var errorableExpress = require('errorable-express');   //the errorable 
> middleware for expressvar common = require('errorable-common');    
> //predefined or customized errorsvar errorable = require('errorable');        
>    //the errorable libraryvar Generator = errorable.Generator;             
> //Get the generatorvar errors = new Generator(common, 'zh-CN').errors;    
> //Generate the errors
> express.use(errorableExpress(errors));             //added errorable to 
> expressjs as a middleware
> express.get('/', function indexxx(req, res) {
>   res.restify(res.errors.Success);                //We get extended res 
> object with new apis and the errors attribute.
> });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();
> });
>
> Thanks & enjoy.
>
>
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/8e7458a2-a1b2-4735-a5c9-a64d2d70cd72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to