From b255c6bbff4dc6a8b5299e193511ea980612071a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 20 Aug 2024 21:01:16 -0700 Subject: save cash endpoint --- index.js | 1 + routes/ecash.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/index.js b/index.js index 7b1517fe..6b47fce8 100644 --- a/index.js +++ b/index.js @@ -119,6 +119,7 @@ app.post("/hidepay", admin, users.hidepay); app.post("/unlimit", admin, users.unlimit); app.get("/cash/:id", ecash.get); +app.post("/cash", ecash.save); app.post("/claim", auth, ecash.claim); app.post("/mint", auth, ecash.mint); app.post("/melt", auth, ecash.melt); diff --git a/routes/ecash.js b/routes/ecash.js index 8ce841dd..d7a9fe7b 100644 --- a/routes/ecash.js +++ b/routes/ecash.js @@ -10,6 +10,17 @@ import store from "$lib/store"; let { ecash: type } = types; export default { + async save({ body: { token } }, res) { + try { + let id = v4(); + await s(`cash:${id}`, token); + res.send({ id }); + } catch (e) { + console.log(e) + bail(res, e.message); + } + }, + async get({ params: { id } }, res) { try { let token = await g(`cash:${id}`); -- cgit v1.2.3