Skip to content

Commit

Permalink
fix: handle errors on body getter function
Browse files Browse the repository at this point in the history
  • Loading branch information
dubisdev committed Dec 2, 2022
1 parent 8c7b56d commit 5a2c17b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export async function setupOAuthServer() {
}

const requestListener: RequestListener = async (req, res) => {
const jsonreq = await getRequestBody(req);
let jsonreq: DoistCardRequest;
try {
jsonreq = await getRequestBody(req);
} catch (e) {
return res.end();
}

if (!isRequestValid(req, jsonreq)) return res.writeHead(401).end();

Expand Down

0 comments on commit 5a2c17b

Please sign in to comment.