- Add nostr-rs-relay service to docker-compose for persistent comments, reactions, and profiles on the dev server - Add one-shot seeder container that auto-populates the relay with test personas, reactions, and comments on first deploy - Proxy WebSocket connections through nginx at /relay so the frontend connects to the relay on the same host (no CORS) - Make relay URL dynamic: reads from VITE_NOSTR_RELAYS in dev, auto-detects /relay proxy path in production Docker builds - Make seed scripts configurable via RELAY_URL and ORIGIN env vars - Add wait-for-relay script for reliable container orchestration - Add "Resume last played" hero banner on My List tab Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import { Relay } from 'applesauce-relay'
|
|
import { PrivateKeySigner } from 'applesauce-signers/signers/private-key-signer'
|
|
import {
|
|
TEST_PERSONAS,
|
|
TASTEMAKER_PERSONAS,
|
|
} from '../src/data/testPersonas.js'
|
|
|
|
const RELAY_URL = process.env.RELAY_URL || 'ws://localhost:7777'
|
|
|
|
type Persona = { name: string; nsec: string; pubkey: string }
|
|
|
|
function buildProfile(persona: Persona, role: 'test' | 'tastemaker') {
|
|
const about =
|
|
role === 'tastemaker'
|
|
? `${persona.name} — tastemaker for IndeeHub`
|
|
: `${persona.name} — test persona for IndeeHub`
|
|
|
|
return {
|
|
name: persona.name,
|
|
display_name: persona.name,
|
|
about,
|
|
picture: `https://robohash.org/${persona.pubkey}.png`,
|
|
bot: true,
|
|
}
|
|
}
|
|
|
|
async function seedProfiles() {
|
|
const relay = new Relay(RELAY_URL)
|
|
|
|
const allPersonas: { persona: Persona; role: 'test' | 'tastemaker' }[] = [
|
|
...TEST_PERSONAS.map((p) => ({ persona: p as Persona, role: 'test' as const })),
|
|
...TASTEMAKER_PERSONAS.map((p) => ({ persona: p as Persona, role: 'tastemaker' as const })),
|
|
]
|
|
|
|
const now = Math.floor(Date.now() / 1000)
|
|
|
|
for (const { persona, role } of allPersonas) {
|
|
const signer = PrivateKeySigner.fromKey(persona.nsec)
|
|
const profile = buildProfile(persona, role)
|
|
|
|
const signed = await signer.signEvent({
|
|
kind: 0,
|
|
created_at: now,
|
|
tags: [],
|
|
content: JSON.stringify(profile),
|
|
})
|
|
|
|
try {
|
|
const res = await relay.publish(signed, { timeout: 5000 })
|
|
console.log(`✓ ${persona.name} (${role}): ${res.ok ? 'OK' : res.message}`)
|
|
} catch (err) {
|
|
console.error(`✗ ${persona.name} (${role}):`, err)
|
|
}
|
|
}
|
|
|
|
// Give relay time to flush, then exit
|
|
setTimeout(() => process.exit(0), 1000)
|
|
}
|
|
|
|
seedProfiles().catch((err) => {
|
|
console.error('Fatal:', err)
|
|
process.exit(1)
|
|
})
|