ekzyis d237861ff5
Use module path aliases (#938)
* Use module path aliases

* fix broken refactor

* path mapping for svgs, style, and remaining places (bonus: lose babel dep)

---------

Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2024-03-19 19:37:31 -05:00

29 lines
704 B
JavaScript

import models from '@/api/models'
export default async function Nip05 ({ query: { name } }, res) {
const names = {}
let relays = {}
const users = await models.user.findMany({
where: {
name,
nostrPubkey: { not: null }
},
include: { nostrRelays: true }
})
for (const user of users) {
names[user.name] = user.nostrPubkey
if (user.nostrRelays.length) {
// append relays with key pubkey
relays[user.nostrPubkey] = []
for (const relay of user.nostrRelays) {
relays[user.nostrPubkey].push(relay.nostrRelayAddr)
}
}
}
relays = Object.keys(relays).length ? relays : undefined
return res.status(200).json({ names, relays })
}