@growsari/response
v0.0.3
Published
For generating standard API and microservice responses
Downloads
435
Keywords
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)
}
}