Files
einundzwanzig.space/tasks/generate_nostr.js
Dennis Reimann afcc5a41cd Nostr updates
2024-09-17 16:39:56 +02:00

34 lines
1.0 KiB
JavaScript

const { mkdirSync, writeFileSync } = require('fs')
const { dirname, resolve } = require('path')
const { NDKUser } = require('@nostr-dev-kit/ndk')
const team = require('../content/team.json')
const { npub } = require('../content/meta.json')
const einundzwanzig = new NDKUser({ npub: npub.einundzwanzig })
const nostrtalk = new NDKUser({ npub: npub.nostrTalk })
const zitadelle = new NDKUser({ npub: npub.zitadelle })
const names = {
"_": einundzwanzig.pubkey,
"einundzwanzig": einundzwanzig.pubkey,
"nostrtalk": nostrtalk.pubkey,
"zitadelle": zitadelle.pubkey
}
const relays = {
[npub.einundzwanzig]: [
"wss://nostr.einundzwanzig.space"
]
}
Object.entries(team).forEach(([key, { nostr: npub }]) => {
if (!npub) return
const id = key.replace(/[\s]/g, '_')
names[id] = new NDKUser({ npub }).pubkey
})
const dst = resolve(__dirname, '..', 'dist', '.well-known', 'nostr.json')
const dir = dirname(dst)
const res = { names, relays }
mkdirSync(dir, { recursive: true })
writeFileSync(dst, JSON.stringify(res, null, 2))