diff options
Diffstat (limited to 'backend/src/routes')
| -rw-r--r-- | backend/src/routes/score.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/backend/src/routes/score.ts b/backend/src/routes/score.ts index d0fdc56..54e4784 100644 --- a/backend/src/routes/score.ts +++ b/backend/src/routes/score.ts @@ -110,6 +110,36 @@ export const handleScoreUpload = async ( } }; +export const handleScoreDeletion = async ( + req: express.Request, + res: express.Response, +) => { + try { + const { userId, internalGameName, scoreId } = req.query; + if (!userId || !internalGameName || !scoreId) { + return res.status(400).json({ error: "Missing required parameters" }); + } + + const userIdNumber = parseInt(userId as string); + const scoreIdNumber = parseInt(scoreId as string); + + await prisma.score.deleteMany({ + where: { + userId: userIdNumber, + gameInternalName: internalGameName as string, + id: scoreIdNumber, + }, + }); + + res.status(200).json({ message: "Scores deleted successfully" }); + } catch (error) { + console.error("Score deletion endpoint error:", error); + res + .status(500) + .json({ error: "Internal server error. Unable to delete scores" }); + } +}; + export const handleGetScores = async ( req: express.Request, res: express.Response, |
