mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-05 00:32:03 +00:00
Try adding lnurlp logic into .well-known endpoint directly instead of redirect endpoint
This commit is contained in:
parent
db9f922175
commit
6a8634f2a4
@ -1,10 +1,46 @@
|
||||
import appConfig from "@/config/appConfig"
|
||||
import { runMiddleware, corsMiddleware } from "@/utils/corsMiddleware";
|
||||
import { getLightningAddressByName } from "@/db/models/lightningAddressModels";
|
||||
|
||||
const BACKEND_URL = process.env.BACKEND_URL
|
||||
const ZAP_PUBKEY = process.env.ZAP_PUBKEY
|
||||
|
||||
export default async function handler(req, res) {
|
||||
// Run CORS middleware first
|
||||
await runMiddleware(req, res, corsMiddleware);
|
||||
|
||||
// Redirect to your lightning address endpoint
|
||||
const { slug } = req.query;
|
||||
res.redirect(307, `/api/lightning-address/lnurlp/${slug}`);
|
||||
|
||||
if (!slug || slug === 'undefined') {
|
||||
res.status(404).json({ error: 'Not found' })
|
||||
return
|
||||
}
|
||||
|
||||
let foundAddress = null;
|
||||
const customAddress = appConfig.customLightningAddresses.find(addr => addr.name === slug);
|
||||
|
||||
if (customAddress) {
|
||||
foundAddress = customAddress;
|
||||
} else {
|
||||
foundAddress = await getLightningAddressByName(slug);
|
||||
}
|
||||
|
||||
if (!foundAddress) {
|
||||
res.status(404).json({ error: 'Lightning address not found' })
|
||||
return
|
||||
}
|
||||
|
||||
const metadata = [
|
||||
["text/plain", `${foundAddress.description}`]
|
||||
];
|
||||
|
||||
res.status(200).json({
|
||||
callback: `${BACKEND_URL}/api/lightning-address/callback/${foundAddress.name}`,
|
||||
maxSendable: foundAddress.maxSendable || 10000000000,
|
||||
minSendable: foundAddress.minSendable || 1000,
|
||||
metadata: JSON.stringify(metadata),
|
||||
tag: 'payRequest',
|
||||
allowsNostr: true,
|
||||
nostrPubkey: ZAP_PUBKEY
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user