import * as plugins from '../plugins.ts'; import type { StackGalleryRegistry } from '../registry.ts'; import * as handlers from './handlers/index.ts'; export class OpsServer { public registryRef: StackGalleryRegistry; public typedrouter = new plugins.typedrequest.TypedRouter(); // Handler instances public authHandler!: handlers.AuthHandler; public organizationHandler!: handlers.OrganizationHandler; public repositoryHandler!: handlers.RepositoryHandler; public packageHandler!: handlers.PackageHandler; public tokenHandler!: handlers.TokenHandler; public auditHandler!: handlers.AuditHandler; public adminHandler!: handlers.AdminHandler; public oauthHandler!: handlers.OAuthHandler; public userHandler!: handlers.UserHandler; constructor(registryRef: StackGalleryRegistry) { this.registryRef = registryRef; } /** * Initialize all handlers. Must be called before routing requests. */ public async start(): Promise { // AuthHandler must be initialized first (other handlers depend on its guards) this.authHandler = new handlers.AuthHandler(this); await this.authHandler.initialize(); // All other handlers self-register in their constructors this.organizationHandler = new handlers.OrganizationHandler(this); this.repositoryHandler = new handlers.RepositoryHandler(this); this.packageHandler = new handlers.PackageHandler(this); this.tokenHandler = new handlers.TokenHandler(this); this.auditHandler = new handlers.AuditHandler(this); this.adminHandler = new handlers.AdminHandler(this); this.oauthHandler = new handlers.OAuthHandler(this); this.userHandler = new handlers.UserHandler(this); console.log('[OpsServer] TypedRequest handlers initialized'); } /** * Cleanup resources */ public async stop(): Promise { console.log('[OpsServer] Stopped'); } }