For generating standard API and microservice responses
npm install @growsari/responseConvenience functions. Use in conjunction with errors; attributes retrieved from errors will show up in the response.
``
const { api } = require('@growsari/response')
async function serverlessHandler(event, ...) {
try {
// implementation
api.success(await someFunction())
} catch (e) {
api.error(e)
}
}
`
`
const { microservice } = require('@growsari/response')
async function serverlessHandler(event, ...) {
try {
// implementation
microservice.success(await someFunction())
} catch (e) {
microservice.error(e)
}
}
``