|
1 | 1 | import { createSettings } from '../settings-factory' |
2 | 2 | import { AlbyNwcPaymentsProcessor } from '../../payments-processors/alby-nwc-payments-processor' |
| 3 | +import { createLogger } from '../logger-factory' |
3 | 4 | import { IPaymentsProcessor } from '../../@types/clients' |
4 | 5 | import { Settings } from '../../@types/settings' |
5 | 6 |
|
| 7 | +const debug = createLogger('alby-nwc-payments-processor-factory') |
| 8 | + |
6 | 9 | const getAlbyNwcConfig = (settings: Settings): { nwcUrl: string; replyTimeoutMs: number } => { |
7 | 10 | const nwcUrl = process.env.ALBY_NWC_URL |
8 | 11 |
|
9 | 12 | if (!nwcUrl) { |
10 | 13 | const error = new Error('ALBY_NWC_URL must be set.') |
11 | | - console.error('Unable to create Alby NWC payments processor.', error) |
| 14 | + debug('Unable to create Alby NWC payments processor. %o', error) |
12 | 15 | throw error |
13 | 16 | } |
14 | 17 |
|
15 | 18 | if (!nwcUrl.startsWith('nostr+walletconnect://') && !nwcUrl.startsWith('nostrwalletconnect://')) { |
16 | 19 | const error = new Error('ALBY_NWC_URL must be a valid nostr+walletconnect:// or nostrwalletconnect:// URI.') |
17 | | - console.error('Unable to create Alby NWC payments processor.', error) |
| 20 | + debug('Unable to create Alby NWC payments processor. %o', error) |
18 | 21 | throw error |
19 | 22 | } |
20 | 23 |
|
21 | 24 | try { |
22 | 25 | new URL(nwcUrl) |
23 | 26 | } catch { |
24 | 27 | const error = new Error('ALBY_NWC_URL is not parseable as a URL.') |
25 | | - console.error('Unable to create Alby NWC payments processor.', error) |
| 28 | + debug('Unable to create Alby NWC payments processor. %o', error) |
26 | 29 | throw error |
27 | 30 | } |
28 | 31 |
|
29 | 32 | const replyTimeoutMs = settings.paymentsProcessors?.alby?.replyTimeoutMs |
30 | 33 | if (typeof replyTimeoutMs !== 'number' || replyTimeoutMs <= 0) { |
31 | 34 | const error = new Error('Setting paymentsProcessors.alby.replyTimeoutMs must be a positive number.') |
32 | | - console.error('Unable to create Alby NWC payments processor.', error) |
| 35 | + debug('Unable to create Alby NWC payments processor. %o', error) |
33 | 36 | throw error |
34 | 37 | } |
35 | 38 |
|
|
0 commit comments