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

@ -14,6 +14,10 @@ import { paymentService } from '@/core/services/PaymentService'
import { visibilityService } from '@/core/services/VisibilityService'
import { storageService } from '@/core/services/StorageService'
import { toastService } from '@/core/services/ToastService'
import { InvoiceService } from '@/core/services/invoiceService'
// Create service instances
const invoiceService = new InvoiceService()
/**
* Base Module Plugin
@ -44,6 +48,9 @@ export const baseModule: ModulePlugin = {
// Register toast service
container.provide(SERVICE_TOKENS.TOAST_SERVICE, toastService)
// Register invoice service
container.provide(SERVICE_TOKENS.INVOICE_SERVICE, invoiceService)
// Register PWA service
container.provide('pwaService', pwaService)
@ -92,6 +99,7 @@ export const baseModule: ModulePlugin = {
visibilityService,
storageService,
toastService,
invoiceService,
pwaService
},