Gas Station Feature

This commit is contained in:
Eric Gullickson
2025-11-04 18:46:46 -06:00
parent d8d0ada83f
commit 5dc58d73b9
61 changed files with 12952 additions and 52 deletions

View File

@@ -0,0 +1,71 @@
/**
* Runtime Configuration Types
*
* Configuration loaded at container startup from secrets.
* Mirrors Kubernetes deployment patterns where secrets are mounted as files
* and read at runtime before application initialization.
*/
/**
* Application runtime configuration
* Loaded from window.CONFIG set by /config.js
*/
export interface AppConfig {
/** Google Maps JavaScript API key for map visualization */
googleMapsApiKey: string;
}
/**
* Window augmentation for runtime config
* config.js is loaded before the React app initializes
*/
declare global {
interface Window {
CONFIG?: AppConfig;
}
}
/**
* Get application configuration with validation
* Throws if required configuration is missing
*
* @returns Application configuration object
* @throws Error if configuration is not loaded or invalid
*/
export function getConfig(): AppConfig {
if (!window.CONFIG) {
throw new Error(
'Application configuration not loaded. Ensure config.js is loaded before the app initializes.'
);
}
return window.CONFIG;
}
/**
* Get Google Maps API key
* Returns empty string if key is not available (graceful fallback)
*
* @returns Google Maps API key or empty string
*/
export function getGoogleMapsApiKey(): string {
try {
const config = getConfig();
return config.googleMapsApiKey || '';
} catch {
console.warn(
'Google Maps API key not available. Maps functionality will be limited.'
);
return '';
}
}
/**
* Check if configuration is available
* Useful for conditional feature enablement
*
* @returns true if config is loaded, false otherwise
*/
export function isConfigLoaded(): boolean {
return !!window.CONFIG;
}