Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
default status to 200
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodepixi committed Feb 10, 2021
1 parent 6729cbf commit 01ac2bd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/graphql_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default async function graphqlProxy(userReq: http.IncomingMessage, userRe
});

userReq.on('end', async () => {
let status = 200;
let reqBodyObject: Record<string, unknown> | undefined;
try {
reqBodyObject = JSON.parse(reqBodyString);
Expand All @@ -40,7 +41,6 @@ export default async function graphqlProxy(userReq: http.IncomingMessage, userRe
const response = await client.query(options);
body = response.body;
} catch (err) {
let status;
switch (err.constructor.name) {
case 'MissingRequiredArgument':
status = 400;
Expand All @@ -54,9 +54,9 @@ export default async function graphqlProxy(userReq: http.IncomingMessage, userRe
default:
status = 500;
}
userRes.statusCode = status;
body = err.message;
} finally {
userRes.statusCode = status;
userRes.end(JSON.stringify(body));
}
return resolve();
Expand Down

0 comments on commit 01ac2bd

Please # to comment.