Skip to content

Commit

Permalink
Fix issue where input querystring is not parsed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
wqyeo committed Mar 29, 2024
1 parent 520213d commit 280b65b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions SpyGamersApi/src/controllers/accounts/getUserInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { PrismaClient, Prisma } from '@prisma/client';
export const getUserInfo = async (request: FastifyRequest, reply: FastifyReply) => {
const prisma = new PrismaClient();
try {
const { account_id } = request.query as { account_id: number; };
const { account_id } = request.query as { account_id: string; };

const user = await prisma.account.findFirst({
where: {
id: account_id
id: Number.parseInt(account_id)
}
})

if (!user) {
return reply.status(200).send({ status: "NO_USERS_FOUND" });
return reply.status(200).send({ status: "NOT_FOUND" });
}

const resultData = {
Expand All @@ -28,6 +28,7 @@ export const getUserInfo = async (request: FastifyRequest, reply: FastifyReply)
result: resultData
});
} catch (error) {
console.log(error)
reply.status(500).send({ status: "FAILURE", exists: false });
} finally {
await prisma.$disconnect();
Expand Down

0 comments on commit 280b65b

Please sign in to comment.