Skip to content

Commit

Permalink
add back responses
Browse files Browse the repository at this point in the history
  • Loading branch information
baileytincher committed May 26, 2021
1 parent 940e2e2 commit 0594121
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ export type TShallotSocketEvent<

const ShallotSocketWrapper = <TEvent extends TShallotSocketEvent = TShallotSocketEvent>(
handler: ShallotRawHandler<TEvent>,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_successStatusCode = 200,
successStatusCode = 200,
middlewareOpts: {
HttpErrorHandlerOpts?: TShallotErrorHandlerOptions;
HttpJsonBodyParserOpts?: TShallotJSONBodyParserOptions;
} = {}
): ShallotAWSHandler<TEvent, APIGatewayProxyResult> => {
const wrappedResponseHandler: Handler = async (...args) => {
await handler(...args);
const res = await handler(...args);
return {
statusCode: successStatusCode,
body: res == null ? undefined : JSON.stringify(res),
};
};

const wrapper = ShallotAWS(wrappedResponseHandler)
Expand Down

0 comments on commit 0594121

Please sign in to comment.