Refactor services to extend BaseService for improved structure and dependency management
- Update AuthService and RelayHub to extend BaseService, introducing standardized initialization and metadata handling. - Implement service-specific initialization methods in both services, enhancing error handling and logging. - Modify NostrmarketService to inherit from BaseService, ensuring consistent dependency management and initialization. - Refactor market module to dynamically import NostrmarketService, improving service registration and initialization flow. - Enhance debug logging across services for better traceability during initialization and operation.
This commit is contained in:
parent
8d4c389f71
commit
dc4da570a7
5 changed files with 151 additions and 50 deletions
|
|
@ -9,8 +9,7 @@ import MarketSettings from './components/MarketSettings.vue'
|
|||
import MerchantStore from './components/MerchantStore.vue'
|
||||
import ShoppingCart from './components/ShoppingCart.vue'
|
||||
|
||||
// Import services
|
||||
import { NostrmarketService } from './services/nostrmarketService'
|
||||
// NostrmarketService will be dynamically imported in install()
|
||||
|
||||
// Store will be imported when needed
|
||||
|
||||
|
|
@ -46,8 +45,19 @@ export const marketModule: ModulePlugin = {
|
|||
throw new Error('Market module requires configuration')
|
||||
}
|
||||
|
||||
// Create and register services
|
||||
const nostrmarketService = new NostrmarketService()
|
||||
// Import the singleton instance
|
||||
const { nostrmarketService } = await import('./services/nostrmarketService')
|
||||
|
||||
// Initialize the service (will handle dependency injection)
|
||||
await nostrmarketService.initialize({
|
||||
waitForDependencies: true,
|
||||
maxRetries: 3
|
||||
}).catch(error => {
|
||||
console.warn('🛒 NostrmarketService initialization deferred:', error)
|
||||
// Service will auto-initialize when dependencies are available
|
||||
})
|
||||
|
||||
// Register the service
|
||||
container.provide(NOSTRMARKET_SERVICE_TOKEN, nostrmarketService)
|
||||
|
||||
// Register global components
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue