- Introduced an HTTP server to facilitate communication with the application. - Added route handlers for managing application configuration, including getting and updating settings. - Implemented notification operations with routes for retrieving, marking, and deleting notifications. - Created project and session management routes to list projects, sessions, and their details. - Developed SSH connection management routes for connecting, disconnecting, and retrieving SSH state and configuration. - Enhanced the application architecture to support real-time event streaming via Server-Sent Events (SSE). This commit significantly expands the application's capabilities by integrating an HTTP server and various management routes, improving user interaction and functionality.
65 lines
2 KiB
TypeScript
65 lines
2 KiB
TypeScript
/**
|
|
* HTTP Route Registration Orchestrator.
|
|
*
|
|
* Registers all domain-specific route handlers on a Fastify instance.
|
|
* Each route file mirrors the corresponding IPC handler.
|
|
*/
|
|
|
|
import { createLogger } from '@shared/utils/logger';
|
|
|
|
import { registerConfigRoutes } from './config';
|
|
import { broadcastEvent, registerEventRoutes } from './events';
|
|
import { registerNotificationRoutes } from './notifications';
|
|
import { registerProjectRoutes } from './projects';
|
|
import { registerSearchRoutes } from './search';
|
|
import { registerSessionRoutes } from './sessions';
|
|
import { registerSshRoutes } from './ssh';
|
|
import { registerSubagentRoutes } from './subagents';
|
|
import { registerUpdaterRoutes } from './updater';
|
|
import { registerUtilityRoutes } from './utility';
|
|
import { registerValidationRoutes } from './validation';
|
|
|
|
import type {
|
|
ChunkBuilder,
|
|
DataCache,
|
|
ProjectScanner,
|
|
SessionParser,
|
|
SubagentResolver,
|
|
UpdaterService,
|
|
} from '../services';
|
|
import type { SshConnectionManager } from '../services/infrastructure/SshConnectionManager';
|
|
import type { FastifyInstance } from 'fastify';
|
|
|
|
const logger = createLogger('HTTP:routes');
|
|
|
|
export interface HttpServices {
|
|
projectScanner: ProjectScanner;
|
|
sessionParser: SessionParser;
|
|
subagentResolver: SubagentResolver;
|
|
chunkBuilder: ChunkBuilder;
|
|
dataCache: DataCache;
|
|
updaterService: UpdaterService;
|
|
sshConnectionManager: SshConnectionManager;
|
|
}
|
|
|
|
export function registerHttpRoutes(
|
|
app: FastifyInstance,
|
|
services: HttpServices,
|
|
sshModeSwitchCallback: (mode: 'local' | 'ssh') => Promise<void>
|
|
): void {
|
|
registerProjectRoutes(app, services);
|
|
registerSessionRoutes(app, services);
|
|
registerSearchRoutes(app, services);
|
|
registerSubagentRoutes(app, services);
|
|
registerNotificationRoutes(app);
|
|
registerConfigRoutes(app);
|
|
registerValidationRoutes(app);
|
|
registerUtilityRoutes(app);
|
|
registerSshRoutes(app, services.sshConnectionManager, sshModeSwitchCallback);
|
|
registerUpdaterRoutes(app, services);
|
|
registerEventRoutes(app);
|
|
|
|
logger.info('All HTTP routes registered');
|
|
}
|
|
|
|
export { broadcastEvent };
|