Skip to content

Commit

Permalink
add check balance + allow CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
gandlafbtc committed Feb 15, 2023
1 parent 4015990 commit b681827
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "gandlaf21",
"license": "ISC",
"dependencies": {
"@gandlaf21/cashu-tools": "^0.1.2",
"@gandlaf21/cashu-tools": "^0.1.3",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
Expand Down
8 changes: 6 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('dotenv').config()

const { CashuMint, CashuWallet, getEncodedProofs } = require("@gandlaf21/cashu-ts")
const { Faucet } = require ("@gandlaf21/cashu-tools")
const { Faucet, utils } = require ("@gandlaf21/cashu-tools")
const rateLimit = require('express-rate-limit')
const cors = require('cors');

Expand Down Expand Up @@ -30,10 +30,14 @@ app.get('/', (req, res) => {
res.send({token: responseString})
})

app.get('/balance', async (req, res) => {
res.send({remaining: utils.getAmountForTokenSet(faucet.balance)})
})

app.get('/charge', async (req, res) => {
const token = req.query.token
const message = await faucet.charge(token)
// console.log("all Tokens:", getEncodedProofs(balance ,[{url:process.env.MINT_URL, keysets: [...new Set(faucet.currentToken.map(t=>t.id))]}]))
console.log("all Tokens: ", getEncodedProofs(faucet.balance ,[{url:process.env.MINT_URL, keysets: [...new Set(faucet.currentToken.map(t=>t.id))]}]))
res.send({message})
})

Expand Down

0 comments on commit b681827

Please sign in to comment.