- 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.
68 lines
No EOL
1.7 KiB
TypeScript
68 lines
No EOL
1.7 KiB
TypeScript
import type { App } from 'vue'
|
|
import type { ModulePlugin } from '@/core/types'
|
|
import { container, SERVICE_TOKENS } from '@/core/di-container'
|
|
import { relayHub } from './nostr/relay-hub'
|
|
import { nostrclientHub } from './nostr/nostrclient-hub'
|
|
|
|
// Import auth services
|
|
import { auth } from './auth/auth-service'
|
|
|
|
// Import PWA services
|
|
import { pwaService } from './pwa/pwa-service'
|
|
|
|
/**
|
|
* Base Module Plugin
|
|
* Provides core infrastructure: Nostr, Auth, PWA, and UI components
|
|
*/
|
|
export const baseModule: ModulePlugin = {
|
|
name: 'base',
|
|
version: '1.0.0',
|
|
|
|
async install(_app: App, options?: any) {
|
|
console.log('🔧 Installing base module...')
|
|
|
|
// Register core Nostr services
|
|
container.provide(SERVICE_TOKENS.RELAY_HUB, relayHub)
|
|
container.provide(SERVICE_TOKENS.NOSTR_CLIENT_HUB, nostrclientHub)
|
|
|
|
// Register auth service
|
|
container.provide(SERVICE_TOKENS.AUTH_SERVICE, auth)
|
|
|
|
// Register PWA service
|
|
container.provide('pwaService', pwaService)
|
|
|
|
// Initialize core services
|
|
await relayHub.initialize(options?.config?.nostr?.relays || [])
|
|
await auth.initialize({
|
|
waitForDependencies: false, // Auth has no dependencies
|
|
maxRetries: 1
|
|
})
|
|
|
|
console.log('✅ Base module installed successfully')
|
|
},
|
|
|
|
async uninstall() {
|
|
console.log('🗑️ Uninstalling base module...')
|
|
|
|
// Cleanup Nostr connections
|
|
relayHub.disconnect()
|
|
nostrclientHub.disconnect?.()
|
|
|
|
console.log('✅ Base module uninstalled')
|
|
},
|
|
|
|
services: {
|
|
relayHub,
|
|
nostrclientHub,
|
|
auth,
|
|
pwaService
|
|
},
|
|
|
|
// No routes - base module is pure infrastructure
|
|
routes: [],
|
|
|
|
// No UI components at module level - they'll be imported as needed
|
|
components: {}
|
|
}
|
|
|
|
export default baseModule |