Skip to content

samover/guinan-api-responder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

This module exposes a node/express response handler to be used consistently across all the iCapps API's.

Installation

  • yarn add guinan-api-responder
  • const Responder = require('guinan-api-responder')

Usage

ErrorResponse

The Responder expects a guinan-api-errors object, otherwise it will transform it to an InternalServerError. The errorHandler returns a json object following the JSON API standards.

Responder.error(res, error);

SuccessResponse

Responder.success(res, { 
  status: 200, 
  payload: { 
    response: "Success" 
  });

You can pass any payload you want, but it is recommended to use jsonapi-serializer or my wrapper guinan-api-serializer.

Development

Clone the repo and install dependencies: yarn. Run the tests with yarn test.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published