import 'dotenv/config' import { always } from '@welshman/lib' import { normalizeRelayUrl } from '@welshman/util' import { Nip01Signer } from '@welshman/signer' import { routerContext } from '@welshman/router' if (!process.env.MAILSHIP_URL) throw new Error('MAILSHIP_URL is not defined.') if (!process.env.MAILSHIP_NAME) throw new Error('MAILSHIP_NAME is not defined.') if (!process.env.MAILSHIP_SECRET) throw new Error('MAILSHIP_SECRET is not defined.') if (!process.env.SMTP_HOST) throw new Error('SMTP_HOST is not defined.') if (!process.env.SMTP_PORT) throw new Error('SMTP_PORT is not defined.') if (!process.env.SMTP_USER) throw new Error('SMTP_USER is not defined.') if (!process.env.SMTP_PASSWORD) throw new Error('SMTP_PASSWORD is not defined.') if (!process.env.SMTP_FROM) throw new Error('SMTP_FROM is not defined.') if (!process.env.DEFAULT_RELAYS) throw new Error('DEFAULT_RELAYS is not defined.') if (!process.env.INDEXER_RELAYS) throw new Error('INDEXER_RELAYS is not defined.') if (!process.env.SEARCH_RELAYS) throw new Error('SEARCH_RELAYS is not defined.') if (!process.env.PORT) console.log('PORT not set, defaulting to 4738') if (!process.env.CORS_ORIGIN) throw new Error('CORS_ORIGIN is not defined.') if (!process.env.BASE_URL) throw new Error('BASE_URL is not defined.') export const MAILSHIP_URL = process.env.MAILSHIP_URL export const MAILSHIP_NAME = process.env.MAILSHIP_NAME export const BASE_URL = process.env.BASE_URL export const EVENT_VIEWER_URL = process.env.EVENT_VIEWER_URL || 'https://app.flotilla.social' export const BRAND_ACCENT = process.env.BRAND_ACCENT || '#7161FF' export const BRAND_NAME = process.env.BRAND_NAME || 'Flotilla' export const BRAND_LOGO = process.env.BRAND_LOGO || `${EVENT_VIEWER_URL.replace(/\/$/, '')}/logo.png` export const appSigner = Nip01Signer.fromSecret(process.env.MAILSHIP_SECRET) export const DEFAULT_RELAYS = process.env.DEFAULT_RELAYS.split(',').map(normalizeRelayUrl) export const INDEXER_RELAYS = process.env.INDEXER_RELAYS.split(',').map(normalizeRelayUrl) export const SEARCH_RELAYS = process.env.SEARCH_RELAYS.split(',').map(normalizeRelayUrl) export const CORS_ORIGIN = process.env.CORS_ORIGIN export const PORT = process.env.PORT || '4738' export const SMTP_HOST = process.env.SMTP_HOST export const SMTP_PORT = process.env.SMTP_PORT export const SMTP_USER = process.env.SMTP_USER export const SMTP_PASSWORD = process.env.SMTP_PASSWORD export const SMTP_FROM = process.env.SMTP_FROM appSigner.getPubkey().then(pubkey => { console.log(`Running as ${pubkey}`) }) routerContext.getDefaultRelays = always(DEFAULT_RELAYS) routerContext.getIndexerRelays = always(INDEXER_RELAYS) routerContext.getSearchRelays = always(SEARCH_RELAYS)