diff --git a/src/index.js b/src/index.js index 75b0da5..dd893c1 100644 --- a/src/index.js +++ b/src/index.js @@ -638,6 +638,7 @@ app.post(SUBSCRIBE_PATH, async (req, res) => { const PUT_PATH = "/put"; app.post(PUT_PATH, async (req, res) => { try { + console.log('hit the PUT handler') const { npub, data, pwh, name } = req.body; if (!(await verifyAuthNostr(req, npub, PUT_PATH))) { @@ -662,7 +663,7 @@ app.post(PUT_PATH, async (req, res) => { new Date(), "put", npub, - "to", + "for", name, data, pwh2, @@ -689,7 +690,7 @@ app.post(PUT_PATH, async (req, res) => { data, pwh2, salt, - name, + name, timestamp: Date.now(), }, }) @@ -822,7 +823,7 @@ app.post(NAME_PATH, async (req, res) => { } try { - console.log('crea') + console.log('creating a name: ' + name, npub) const dbr = await prisma.names.create({ data: { npub, @@ -959,6 +960,7 @@ app.put(NAME_PATH, async (req, res) => { } try { + console.log('creating a name: ' + name, newNpub) const dbr = await prisma.names.create({ data: { npub: newNpub, @@ -987,6 +989,44 @@ app.put(NAME_PATH, async (req, res) => { } }); +const TEST_PATH = "/debug"; +app.get(TEST_PATH, async (req, res) => { + const { name } = req.query; + console.log('passed name: ', name); + const { data: bunkerNsec } = nip19.decode(BUNKER_NSEC); + const bunkerPubkey = getPublicKey(bunkerNsec); + + const data = { + names: { + _: bunkerPubkey, + }, + nip46: {}, + // FIXME remove when ndk is fixed + relays: {}, + }; + data.nip46[bunkerPubkey] = [BUNKER_RELAY]; + + + const rec = await prisma.names.findUnique({ + where: { + name, + }, + }); + + console.log("name result: ", name, rec); + + + const names = await prisma.names.findMany(); + console.log('length of names: ', names.length); + names.forEach( (nameResult) => { + console.log('name result: ', nameResult) + }); + res.status(200).send({ + name: name, + data: data + }); +}); + const JSON_PATH = "/.well-known/nostr.json"; app.get(JSON_PATH, async (req, res) => { try { @@ -1004,6 +1044,7 @@ app.get(JSON_PATH, async (req, res) => { data.nip46[bunkerPubkey] = [BUNKER_RELAY]; const { name } = req.query; + console.log('name: ' + name) if (!name) { res.status(200).send(data); return; @@ -1014,7 +1055,7 @@ app.get(JSON_PATH, async (req, res) => { name, }, }); - console.log("name", name, rec); + console.log("name result: ", name, rec); if (rec && !rec.disabled) { const { data: pubkey } = nip19.decode(rec.npub);