mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 20:23:36 +00:00
refactor: encapsulate state management for spec and suggestions generation
- Made the generation status variables private and introduced getter functions for both spec and suggestions generation states. - Updated relevant route handlers to utilize the new getter functions, improving encapsulation and reducing direct access to shared state. - Enhanced code maintainability by centralizing state management logic.
This commit is contained in:
@@ -12,8 +12,29 @@ import {
|
||||
|
||||
const logger = createLogger("Setup");
|
||||
|
||||
// Storage for API keys (in-memory cache)
|
||||
export const apiKeys: Record<string, string> = {};
|
||||
// Storage for API keys (in-memory cache) - private
|
||||
const apiKeys: Record<string, string> = {};
|
||||
|
||||
/**
|
||||
* Get an API key for a provider
|
||||
*/
|
||||
export function getApiKey(provider: string): string | undefined {
|
||||
return apiKeys[provider];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an API key for a provider
|
||||
*/
|
||||
export function setApiKey(provider: string, key: string): void {
|
||||
apiKeys[provider] = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all API keys (for read-only access)
|
||||
*/
|
||||
export function getAllApiKeys(): Record<string, string> {
|
||||
return { ...apiKeys };
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to persist API keys to .env file
|
||||
|
||||
Reference in New Issue
Block a user