diff options
| author | Adam Soltys <[email protected]> | 2024-08-20 09:59:07 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-08-20 09:59:07 -0700 |
| commit | 03108b9c787a9fdd087c0a2242879a18ff8fd0d9 (patch) | |
| tree | 50c0c1c0ea155d7317d54f4ac26877c147fce57a | |
| parent | 00f0cda6a4c1ace9eea435e0bcc40a6004d70fdf (diff) | |
| download | coinos-server-03108b9c787a9fdd087c0a2242879a18ff8fd0d9.tar.gz coinos-server-03108b9c787a9fdd087c0a2242879a18ff8fd0d9.zip | |
get cash route
| -rw-r--r-- | index.js | 1 | ||||
| -rw-r--r-- | routes/ecash.js | 13 |
2 files changed, 13 insertions, 1 deletions
@@ -118,6 +118,7 @@ app.post("/shopify/:id", shopify); app.post("/hidepay", admin, users.hidepay); app.post("/unlimit", admin, users.unlimit); +app.get("/cash/:id", ecash.get); 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 eb69798f..1b8bcae1 100644 --- a/routes/ecash.js +++ b/routes/ecash.js @@ -10,6 +10,14 @@ import store from "$lib/store"; let { ecash: type } = types; export default { + async get({ params: { id } }, res) { + try { + res.send(await g(`cash:${id}`)); + } catch (e) { + bail(res, e.message); + } + }, + async claim({ body: { token }, user }, res) { try { let amount = await claim(token); @@ -30,20 +38,23 @@ export default { res.send({ ok: true }); } catch (e) { + console.log(e); bail(res, e.message); } }, async mint({ body: { amount }, user }, res) { try { + let id = v4(); let hash = v4(); let p = await debit({ hash, amount, user, type }); let token = await mint(amount); p.memo = token; await s(`payment:${p.id}`, p); + s(`cash:${id}`, token); - res.send({ token }); + res.send({ id }); } catch (e) { bail(res, e.message); } |
