mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 21:03:08 +00:00
refactor: Modularize Electron main process into single-responsibility components
Extract the monolithic main.ts (~1000 lines) into focused modules: - electron/constants.ts - Window sizing, port defaults, filenames - electron/state.ts - Shared state container - electron/utils/ - Port availability and icon utilities - electron/security/ - API key management - electron/windows/ - Window bounds and main window creation - electron/server/ - Backend and static server management - electron/ipc/ - IPC handlers with shared channel constants Benefits: - Improved testability with isolated modules - Better discoverability and maintainability - Single source of truth for IPC channels (used by both main and preload) - Clear separation of concerns Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
29
apps/ui/src/electron/ipc/auth-handlers.ts
Normal file
29
apps/ui/src/electron/ipc/auth-handlers.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Auth IPC handlers
|
||||
*
|
||||
* Handles authentication-related operations.
|
||||
*/
|
||||
|
||||
import { ipcMain } from 'electron';
|
||||
import { IPC_CHANNELS } from './channels';
|
||||
import { state } from '../state';
|
||||
|
||||
/**
|
||||
* Register auth IPC handlers
|
||||
*/
|
||||
export function registerAuthHandlers(): void {
|
||||
// Get API key for authentication
|
||||
// Returns null in external server mode to trigger session-based auth
|
||||
ipcMain.handle(IPC_CHANNELS.AUTH.GET_API_KEY, () => {
|
||||
if (state.isExternalServerMode) {
|
||||
return null;
|
||||
}
|
||||
return state.apiKey;
|
||||
});
|
||||
|
||||
// Check if running in external server mode (Docker API)
|
||||
// Used by renderer to determine auth flow
|
||||
ipcMain.handle(IPC_CHANNELS.AUTH.IS_EXTERNAL_SERVER_MODE, () => {
|
||||
return state.isExternalServerMode;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user