37 lines
1.9 KiB
TypeScript
37 lines
1.9 KiB
TypeScript
|
|
import 'dotenv/config'
|
||
|
|
import { always } from '@welshman/lib'
|
||
|
|
import { normalizeRelayUrl } from '@welshman/util'
|
||
|
|
import { netContext } from '@welshman/net'
|
||
|
|
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.POSTMARK_API_KEY) throw new Error('POSTMARK_API_KEY is not defined.')
|
||
|
|
if (!process.env.POSTMARK_SENDER_ADDRESS) throw new Error('POSTMARK_SENDER_ADDRESS 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) throw new Error('PORT 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 appSigner = Nip01Signer.fromSecret(process.env.MAILSHIP_SECRET)
|
||
|
|
export const POSTMARK_API_KEY = process.env.POSTMARK_API_KEY
|
||
|
|
export const POSTMARK_SENDER_ADDRESS = process.env.POSTMARK_SENDER_ADDRESS
|
||
|
|
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 PORT = process.env.PORT
|
||
|
|
|
||
|
|
appSigner.getPubkey().then(pubkey => {
|
||
|
|
console.log(`Running as ${pubkey}`)
|
||
|
|
})
|
||
|
|
|
||
|
|
routerContext.getDefaultRelays = always(DEFAULT_RELAYS)
|
||
|
|
routerContext.getIndexerRelays = always(INDEXER_RELAYS)
|
||
|
|
routerContext.getSearchRelays = always(SEARCH_RELAYS)
|