Skip to content

Bundle with services to develop RestAPI server applications with restify

License

Notifications You must be signed in to change notification settings

dragonnodejs/restify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DragonNode.js Restify

Bundle with services to develop RestAPI server applications with restify

  • Make the restify errors as service available
  • Initialize the restify server as service
  • Serves the package information for the application
  • Services for validate input from the client

Installation

  • Run npm install dragonnodejs-restify --save
  • Add the bundle to the "app.js":
let modules = [
    [require('dragonnodejs-restify'), [
        ['errors'],
        ['server', {
            options: {},
            plugins: (restify, server) => {
                server.use(restify.acceptParser(server.acceptable));
                server.use(restify.authorizationParser());
                server.use(restify.bodyParser({ mapParams: false }));
                server.use(restify.CORS());
                server.use(restify.gzipResponse());
                server.use(restify.queryParser({ mapParams: false }));
            },
            listen: [process.env.PORT]
        }],
        ['package', require(__dirname + '/package.json')],
        ['validators', (validator, errors) => [
            ['email', input => {
                input = validator.trim(input);
                if (!validator.isEmail(input)) {
                    throw new errors.BadRequestError('invalid email');
                }
                return input;
            }],
            ['password', input => validator.trim(input)]
        ]]
    ]]
];

About

Bundle with services to develop RestAPI server applications with restify

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published