Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@growsari/response

leland.growsari768ISC0.0.3

For generating standard API and microservice responses

readme

Response

Convenience functions. Use in conjunction with errors; attributes retrieved from errors will show up in the response.

Usage

API Gateway responses

const { api } = require('@growsari/response')

async function serverlessHandler(event, ...) {
  try {
    // implementation
    api.success(await someFunction())
  } catch (e) {
    api.error(e)
  }
}

Lambda microservice response

const { microservice } = require('@growsari/response')

async function serverlessHandler(event, ...) {
  try {
    // implementation
    microservice.success(await someFunction())
  } catch (e) {
    microservice.error(e)
  }
}