Library to build http responses for use in serverless projects
parameter | type | required | description |
---|---|---|---|
body | any | no | the body to be stringified and sent with the response |
status | number | no | status code of the response |
parameter | type | required | description |
---|---|---|---|
body | any | no | the body to be stringified and sent with the response, default above in method signature |
parameter | type | required | description |
---|---|---|---|
body | any | no | the body to be stringified and sent with the response, default above in method signature |
parameter | type | required | description |
---|---|---|---|
body | any | no | the body to be stringified and sent with the response, default above in method signature |
parameter | type | required | description |
---|---|---|---|
body | any | no | the body to be stringified and sent with the response, default above in method signature |
parameter | type | required | description |
---|---|---|---|
body | any | no | the body to be stringified and sent with the response, default above in method signature |
npm i @tractorzoom/http-response@latest
import { executeQuery } from '@tractorzoom/serverless-mysql-utils';
import { ok, internalServerError } from '@tractorzoom/http-response';
export const handler = async () => {
const queryString = `SELECT * FROM MyTable WHERE id = "some-guid"`;
const response = await executeQuery(queryString);
if (response.error) {
return internalServerError(response);
}
return ok(response);
};