Generate nostr.json

This commit is contained in:
Dennis Reimann
2023-08-22 12:59:39 +02:00
parent 06dd31ea4b
commit f7ad62b361
4 changed files with 6099 additions and 318 deletions

30
tasks/generate_nostr.js Normal file
View File

@@ -0,0 +1,30 @@
const pug = require('pug')
const { mkdirSync, writeFileSync } = require('fs')
const { dirname, resolve } = require('path')
const { NDKUser } = require('@nostr-dev-kit/ndk')
const team = require('../content/team.json')
const { nostr: einundzwanzigNpub } = require('../content/meta.json')
const einundzwanzigHex = new NDKUser({ npub: einundzwanzigNpub }).hexpubkey()
const names = {
"_": einundzwanzigHex,
"einundzwanzig": einundzwanzigHex
}
const relays = {
[einundzwanzigHex]: [
"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 }).hexpubkey()
})
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))