Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
samarth52 committed Nov 18, 2024
1 parent 737c38e commit 5f83536
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/pages/api/games/popularity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default async function handler(
case "POST":
return updatePopularityHandler(req, res);
default:
return res.status(HTTP_STATUS_CODE.METHOD_NOT_ALLOWED).send({
return res.status(HTTP_STATUS_CODE.METHOD_NOT_ALLOWED).json({
error: `Request method ${req.method} is not allowed`,
});
}
Expand All @@ -25,15 +25,16 @@ async function updatePopularityHandler(
if (requestKey !== process.env.GAME_POPULARITY_CRON_KEY) {
return res
.status(HTTP_STATUS_CODE.UNAUTHORIZED)
.send({ error: "Invalid secret provided." });
.json({ error: "Invalid secret provided." });
}

await updateGamesPopularity();

return res.status(HTTP_STATUS_CODE.OK).send({ message: "Success" });
return res.status(HTTP_STATUS_CODE.OK).json({ message: "Success" });
} catch (e: any) {
console.error("Error updating game popularity:", e);
return res
.status(HTTP_STATUS_CODE.INTERNAL_SERVER_ERROR)
.send({ error: e.message });
.json({ error: e.message });
}
}

0 comments on commit 5f83536

Please sign in to comment.