Complete LnbitsAPI migration to dependency injection pattern

- Convert LnbitsAPI from singleton to BaseService extension
- Add LNBITS_API service token to DI container
- Register LnbitsAPI service in base module with proper initialization order
- Update AuthService to depend on injected LnbitsAPI instead of singleton
- Fix BaseService to properly track LnbitsAPI dependency in getMissingDependencies
- Update events API functions to use dependency injection
- Resolve initialization timing issue preventing application startup

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
padreug 2025-09-07 01:58:36 +02:00
parent 093846b351
commit 4a3d2012be
6 changed files with 69 additions and 18 deletions

View file

@ -48,6 +48,7 @@ export abstract class BaseService {
protected storageService: any = null
protected toastService: any = null
protected invoiceService: any = null
protected lnbitsAPI: any = null
// Service state
public readonly isInitialized: Ref<boolean> = ref(false)
@ -140,6 +141,7 @@ export abstract class BaseService {
this.storageService = tryInjectService(SERVICE_TOKENS.STORAGE_SERVICE)
this.toastService = tryInjectService(SERVICE_TOKENS.TOAST_SERVICE)
this.invoiceService = tryInjectService(SERVICE_TOKENS.INVOICE_SERVICE)
this.lnbitsAPI = tryInjectService(SERVICE_TOKENS.LNBITS_API)
// Check if all required dependencies are available
const missingDeps = this.getMissingDependencies()
@ -193,6 +195,9 @@ export abstract class BaseService {
if (deps.includes('ToastService') && !this.toastService) {
missing.push('ToastService')
}
if (deps.includes('LnbitsAPI') && !this.lnbitsAPI) {
missing.push('LnbitsAPI')
}
return missing
}

View file

@ -140,6 +140,9 @@ export const SERVICE_TOKENS = {
// Nostrmarket services
NOSTRMARKET_SERVICE: Symbol('nostrmarketService'),
// API services
LNBITS_API: Symbol('lnbitsAPI'),
} as const
// Type-safe injection helpers