aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
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);
+ }
+});