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