diff options
| author | Adam Soltys <[email protected]> | 2022-10-13 18:05:49 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-10-18 21:58:51 -0700 |
| commit | a4cccc51652405d6c3d2b6edd2dba5627c3535ba (patch) | |
| tree | 462cbfdd70674e79cb50156d6562713983ce490d /routes | |
| parent | d97b2543f6b9b5a969e2f9fa93f6064b543a58c5 (diff) | |
| download | coinos-server-a4cccc51652405d6c3d2b6edd2dba5627c3535ba.tar.gz coinos-server-a4cccc51652405d6c3d2b6edd2dba5627c3535ba.zip | |
tickets
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/tickets.js | 19 |
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); + } +}); |
