Skip to content

Commit 26da900

Browse files
authored
Merge pull request #16 from storyofams/fix/manual-response
handle manual res when not returning
2 parents d079ca5 + 6c91d48 commit 26da900

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/internals/handler.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function Handler(method?: HttpVerb): MethodDecorator {
8080

8181
const returnValue = await originalHandler.call(this, ...parameters);
8282

83-
if (returnValue instanceof ServerResponse) {
83+
if (returnValue instanceof ServerResponse || res.headersSent) {
8484
return;
8585
}
8686

@@ -92,8 +92,6 @@ export function Handler(method?: HttpVerb): MethodDecorator {
9292
res.json(returnValue ?? null);
9393
}
9494
} catch (err) {
95-
console.error(err);
96-
9795
const statusCode = err instanceof HttpException ? err.statusCode : 500;
9896
const message = err instanceof HttpException ? err.message : 'An unknown error occurred.';
9997
const errors = err instanceof HttpException && err.errors?.length ? err.errors : [message];

0 commit comments

Comments
 (0)