Migrate PaymentMonitorService to dependency injection pattern
- Convert PaymentMonitorService to extend BaseService with proper metadata - Add invoiceService property to BaseService for payment status checking - Register PaymentMonitorService in market module with DI container - Update market store to use injected service instead of singleton import - Remove exported singleton instance from service file - Add proper service initialization and cleanup in market module This completes the third legacy service migration, following InvoiceService and NostrmarketService. The service now properly integrates with the DI architecture for better testing, lifecycle management, and loose coupling. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
14d6bc6329
commit
093846b351
5 changed files with 59 additions and 20 deletions
|
|
@ -19,6 +19,7 @@ import { useMarketPreloader } from './composables/useMarketPreloader'
|
|||
|
||||
// Import services
|
||||
import { NostrmarketService } from './services/nostrmarketService'
|
||||
import { PaymentMonitorService } from './services/paymentMonitor'
|
||||
|
||||
export interface MarketModuleConfig {
|
||||
defaultCurrency: string
|
||||
|
|
@ -44,11 +45,14 @@ export const marketModule: ModulePlugin = {
|
|||
throw new Error('Market module requires configuration')
|
||||
}
|
||||
|
||||
// Create and register NostrmarketService instance
|
||||
// Create and register service instances
|
||||
const nostrmarketService = new NostrmarketService()
|
||||
container.provide(SERVICE_TOKENS.NOSTRMARKET_SERVICE, nostrmarketService)
|
||||
|
||||
// Initialize the service (will handle dependency injection)
|
||||
const paymentMonitorService = new PaymentMonitorService()
|
||||
container.provide(SERVICE_TOKENS.PAYMENT_MONITOR, paymentMonitorService)
|
||||
|
||||
// Initialize services (will handle dependency injection)
|
||||
await nostrmarketService.initialize({
|
||||
waitForDependencies: true,
|
||||
maxRetries: 3
|
||||
|
|
@ -56,6 +60,14 @@ export const marketModule: ModulePlugin = {
|
|||
console.warn('🛒 NostrmarketService initialization deferred:', error)
|
||||
// Service will auto-initialize when dependencies are available
|
||||
})
|
||||
|
||||
await paymentMonitorService.initialize({
|
||||
waitForDependencies: true,
|
||||
maxRetries: 3
|
||||
}).catch(error => {
|
||||
console.warn('🛒 PaymentMonitorService initialization deferred:', error)
|
||||
// Service will auto-initialize when dependencies are available
|
||||
})
|
||||
|
||||
// Register global components
|
||||
app.component('MarketSettings', MarketSettings)
|
||||
|
|
@ -75,6 +87,7 @@ export const marketModule: ModulePlugin = {
|
|||
|
||||
// Clean up services
|
||||
container.remove(SERVICE_TOKENS.NOSTRMARKET_SERVICE)
|
||||
container.remove(SERVICE_TOKENS.PAYMENT_MONITOR)
|
||||
|
||||
console.log('✅ Market module uninstalled')
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue