lyric-karaoke-cli
Version:
A CLI application for displaying song lyrics in a karaoke-style format
45 lines (36 loc) • 1.14 kB
JavaScript
require('dotenv').config();
/**
* Configuration module that reads API key and other settings from environment variables
*/
const config = {
// API Key for the music API service
apiKey: process.env.API_KEY,
// Base URL for the API
apiBaseUrl: process.env.API_BASE_URL || 'https://api.genius.com',
// Cache settings
cache: {
enabled: process.env.CACHE_ENABLED !== 'false',
directory: process.env.CACHE_DIRECTORY || './.cache',
ttl: parseInt(process.env.CACHE_TTL || '86400', 10) // Default: 24 hours in seconds
},
// CLI settings
cli: {
maxSearchResults: parseInt(process.env.MAX_SEARCH_RESULTS || '10', 10)
}
};
// Validate required configuration
if (!config.apiKey) {
console.warn('API_KEY is not set in environment variables. The application may not function correctly.');
console.log('Please set your API key in the .env file.');
}
/**
* Returns the API key from configuration
* @returns {string|null} The API key or null if not set
*/
const getApiKey = () => {
return config.apiKey;
};
module.exports = {
...config,
getApiKey
};