aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-10-13 18:05:49 -0700
committerAdam Soltys <[email protected]>2022-10-13 18:05:49 -0700
commit81e8a6ac1e61cf812252f08f624f8ccf7b7cb8a5 (patch)
tree4b0dd6d726f218ca979d5abc729c73956e828957 /routes
parent974c0fa9556c294415e5a14d2ba35c2f630b2db7 (diff)
downloadcoinos-server-81e8a6ac1e61cf812252f08f624f8ccf7b7cb8a5.tar.gz
coinos-server-81e8a6ac1e61cf812252f08f624f8ccf7b7cb8a5.zip
tickets
Diffstat (limited to 'routes')
-rw-r--r--routes/tickets.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/routes/tickets.js b/routes/tickets.js
new file mode 100644
index 00000000..0334c2c6
--- /dev/null
+++ b/routes/tickets.js
@@ -0,0 +1,19 @@
+import app from "$app";
+import redis from "$lib/redis";
+import { auth } from "$lib/passport";
+
+app.get("/ticket", async (req, res) => {
+ res.send({ ticket: await redis.lLen("tickets") });
+});
+
+app.post("/ticket", auth, async (req, res) => {
+ try {
+ let { asset } = req.body;
+ if (!asset || asset.length !== 64) throw new Error("invalid asset");
+ await redis.lPush("tickets", req.body.asset);
+
+ res.send(await redis.lPush("tickets", req.body.asset));
+ } catch (e) {
+ res.code(500).send(e.message);
+ }
+});