Migrate InvoiceService to dependency injection pattern

- Add INVOICE_SERVICE token to DI container
- Register InvoiceService in base module with proper lifecycle
- Update market store to use dependency injection instead of singleton
- Remove exported singleton from InvoiceService class
- Add comprehensive migration documentation with examples
- Maintain type safety with proper TypeScript interfaces

This migration eliminates the legacy singleton pattern and improves:
- Testability through service injection
- Modular architecture with clear boundaries
- Single source of truth for service instances
- Consistent dependency injection patterns

🤖 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:10:55 +02:00
parent 6cb10a31db
commit 7a32085ee1
5 changed files with 383 additions and 6 deletions

View file

@ -1,11 +1,10 @@
import { defineStore } from 'pinia'
import { ref, computed, readonly, watch } from 'vue'
import { invoiceService } from '@/core/services/invoiceService'
import { paymentMonitor } from '../services/paymentMonitor'
import { nostrmarketService } from '../services/nostrmarketService'
import { useAuth } from '@/composables/useAuthService'
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
import type { LightningInvoice } from '@/core/services/invoiceService'
import type { LightningInvoice, InvoiceService } from '@/core/services/invoiceService'
import type {
@ -18,6 +17,7 @@ import type {
export const useMarketStore = defineStore('market', () => {
const auth = useAuth()
const storageService = injectService(SERVICE_TOKENS.STORAGE_SERVICE) as any
const invoiceService = injectService(SERVICE_TOKENS.INVOICE_SERVICE) as InvoiceService
// Core market state
const markets = ref<Market[]>([])
const stalls = ref<Stall[]>([])