feat(snapshot): config validiert BOOTSTRAP_RELAY-prefix

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jörg Lohrer 2026-04-28 08:20:29 +02:00
parent 1827817ad5
commit 998e08e073
2 changed files with 9 additions and 0 deletions

View File

@ -11,5 +11,8 @@ export function loadConfig(): Config {
throw new Error('AUTHOR_PUBKEY_HEX muss 64 hex chars sein')
}
if (!bootstrapRelay) throw new Error('BOOTSTRAP_RELAY fehlt in env')
if (!bootstrapRelay.startsWith('wss://') && !bootstrapRelay.startsWith('ws://')) {
throw new Error('BOOTSTRAP_RELAY muss eine wss:// (oder ws://) URL sein')
}
return { authorPubkeyHex, bootstrapRelay }
}

View File

@ -20,3 +20,9 @@ Deno.test('loadConfig wirft bei ungueltigem hex', () => {
Deno.env.set('BOOTSTRAP_RELAY', 'wss://relay.primal.net')
assertThrows(() => loadConfig(), Error, '64 hex')
})
Deno.test('loadConfig wirft bei ungueltigem BOOTSTRAP_RELAY (kein wss://)', () => {
Deno.env.set('AUTHOR_PUBKEY_HEX', '4fa5d1c413e2b45e10d40bf3562ab701a5331206e359c90baae0e99bfd6c6e41')
Deno.env.set('BOOTSTRAP_RELAY', 'http://relay.example.com')
assertThrows(() => loadConfig(), Error, 'wss://')
})