This module exposes a node/express response handler to be used consistently across all the iCapps API's.
yarn add guinan-api-responder
const Responder = require('guinan-api-responder')
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);
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.
Clone the repo and install dependencies: yarn
.
Run the tests with yarn test
.