aboutsummaryrefslogtreecommitdiffstats
path: root/backend/ts/api/won.ts
diff options
context:
space:
mode:
Diffstat (limited to 'backend/ts/api/won.ts')
-rw-r--r--backend/ts/api/won.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/backend/ts/api/won.ts b/backend/ts/api/won.ts
new file mode 100644
index 0000000..1e8287c
--- /dev/null
+++ b/backend/ts/api/won.ts
@@ -0,0 +1,14 @@
+import { Request, Response } from "express";
+import { API_RES, makeQuery } from "../../../helpers/helpersBack";
+
+export default async function won(req: Request, res: Response) {
+ if (req.session === undefined || req.session.gid === undefined || req.session.index === undefined) {
+ console.log(JSON.stringify(req));
+ res.status(400);
+ res.send(API_RES.failure);
+ return;
+ }
+ await makeQuery("UPDATE `fia` SET `winner` = ? WHERE `id` = ?", [req.session.index, req.session.gid]);
+
+ res.send(API_RES.success);
+} \ No newline at end of file