npm.io
0.0.3 • Published 6 years ago

@growsari/response

Licence
ISC
Version
0.0.3
Deps
1
Size
2 kB
Vulns
1
Weekly
0

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)
  }
}