import { Endpoint, presetIrohServices } from '@number0/iroh'
// Apply a preset pointing at your dedicated relays, authenticated with your
// project's API key. In production, load the key from a config file or
// environment variable instead of hardcoding it.
const builder = Endpoint.builder()
presetIrohServices(builder, {
relays: ['YOUR_RELAY_URL_US', 'YOUR_RELAY_URL_EU'],
apiSecret: 'YOUR_API_KEY',
})
// In JavaScript, presets are functions applied to an `EndpointBuilder`, so use
// `Endpoint.builder()` rather than `Endpoint.bind()` — `bind()` always applies the
// n0 preset.
// Bind the endpoint, then wait until it's online to confirm it has an
// authorized connection to a relay.
const ep = await builder.bind()
await ep.online()