Skip to content

Commit a5411e6

Browse files
author
fiatjaf
committed
move routes from /endpoint* to /lnurlpay*
1 parent 62deba2 commit a5411e6

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/lnurl.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,38 @@ module.exports = (app, payListen, model, auth, ln) => async {
2323
, setLnurlPayEndpoint, delLnurlPayEndpoint
2424
} = model
2525

26-
app.get('/endpoints', auth, wrap(async (req, res) =>
26+
app.get('/lnurlpays', auth, wrap(async (req, res) =>
2727
res.status(200).send(
2828
(await listLnurlPayEndpoints())
2929
.map(lnurlpay => addBech32Lnurl(req, lnurlpay))
3030
)))
3131

32-
app.post('/endpoint', auth, wrap(async (req, res) =>
32+
app.post('/lnurlpay', auth, wrap(async (req, res) =>
3333
res.status(201).send(
3434
addBech32Lnurl(req, await setLnurlPayEndpoint(null, req.body))
3535
)))
3636

37-
app.put('/endpoint/:id', auth, wrap(async (req, res) =>
37+
app.put('/lnurlpay/:id', auth, wrap(async (req, res) => {
38+
const endpoint = await getLnurlPayEndpoint(req.params.id)
39+
const updated = {...endpoint, ...req.body}
3840
res.status(200).send(
39-
addBech32Lnurl(req, await setLnurlPayEndpoint(req.params.id, req.body))
40-
)))
41+
addBech32Lnurl(req, await setLnurlPayEndpoint(req.params.id, updated))
42+
)
43+
}))
4144

42-
app.delete('/endpoint/:id', auth, wrap(async (req, res) => {
45+
app.delete('/lnurlpay/:id', auth, wrap(async (req, res) => {
4346
const deletedRows = await delLnurlPayEndpoint(req.params.id)
4447
if (deletedRows) res.status(204)
4548
else res.status(404)
4649
}))
4750

48-
app.get('/endpoint/:id', auth, wrap(async (req, res) => {
51+
app.get('/lnurlpay/:id', auth, wrap(async (req, res) => {
4952
const endpoint = await getLnurlPayEndpoint(req.params.id)
5053
if (endpoint) res.status(200).send(addBech32Lnurl(req, endpoint))
5154
else res.status(404)
5255
}))
5356

54-
app.get('/endpoint/:id/invoices', auth, wrap(async (req, res) =>
57+
app.get('/lnurlpay/:id/invoices', auth, wrap(async (req, res) =>
5558
res.send(await listInvoicesByLnurlPayEndpoint(req.params.id))))
5659

5760
// this is the actual endpoint users will hit

0 commit comments

Comments
 (0)