@diotoborg/voluptatibus-tempore

3.9.112 • Public • Published

@diotoborg/voluptatibus-tempore

Helper functions for API handling on NodeJS. The functions are pure and curried with Ramda.

Build Status Coverage Status npm version Dependency Status

Install

$ npm install @diotoborg/voluptatibus-tempore --save

Run the specs

$ npm test

Usage

// Example API route such as '/users' which could reasonably leverage a 
// 'user' model which would return a promise or catch with an error object.

// The error object passed in the catch should include a 'statusCode' property
// that is specific to the respective error. If it does not, the api utils 
// will default to 500.

// Note: Because the util functions are curried, we can keep them pure and by 
// invoking with req and res, as shown below.

var apiUtils  = require('@diotoborg/voluptatibus-tempore'),
    userModel = require('./models/user');

function getUsers(req, res, next) {
  userModel.getUsers().
    then(apiUtils.jsonResponseSuccess(req, res)).
    catch(apiUtils.jsonResponseError(req, res, next));
};

module.exports = getUsers;

Readme

Keywords

Package Sidebar

Install

npm i @diotoborg/voluptatibus-tempore

Weekly Downloads

437

Version

3.9.112

License

MIT

Unpacked Size

219 kB

Total Files

604

Last publish

Collaborators

  • quochoanglm58