33 lines
1022 B
TypeScript
33 lines
1022 B
TypeScript
import dotenv from 'dotenv';
|
|
|
|
// Load environment variables from .env file
|
|
dotenv.config();
|
|
|
|
export interface AppConfig {
|
|
port: number;
|
|
apiKey: string;
|
|
databasePath: string;
|
|
relayUrls: string[];
|
|
autoRestart: boolean;
|
|
maxRestarts: number;
|
|
logLevel: string;
|
|
}
|
|
|
|
export function loadConfig(): AppConfig {
|
|
return {
|
|
port: parseInt(process.env.PORT || '9090'),
|
|
apiKey: process.env.API_KEY || 'your-api-key-change-this',
|
|
databasePath: process.env.DATABASE_PATH || './data/server.db',
|
|
relayUrls: process.env.RELAY_URLS?.split(',') || ['ws://localhost:8090'],
|
|
autoRestart: process.env.AUTO_RESTART === 'true',
|
|
maxRestarts: parseInt(process.env.MAX_RESTARTS || '10'),
|
|
logLevel: process.env.LOG_LEVEL || 'info'
|
|
};
|
|
}
|
|
|
|
export const config: AppConfig = loadConfig();
|
|
|
|
// Validate required environment variables
|
|
if (!config.apiKey || config.apiKey === 'your-api-key-change-this') {
|
|
console.warn('⚠️ Warning: Using default API key. Set API_KEY environment variable for production.');
|
|
}
|