tv-recommender-mcp-server
Version:
MCP server for TV show recommendations
34 lines (33 loc) • 944 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfig = getConfig;
exports.validateApiKey = validateApiKey;
const dotenv_1 = __importDefault(require("dotenv"));
// 加载环境变量
dotenv_1.default.config();
/**
* 从环境变量中获取配置
*/
function getConfig() {
return {
tmdbApiKey: process.env.TMDB_API_KEY || null,
logLevel: process.env.LOG_LEVEL || 'info'
};
}
/**
* 验证API密钥
* 只在实际需要使用API时调用此函数
* @throws Error 如果API密钥不存在
*/
function validateApiKey() {
const { tmdbApiKey } = getConfig();
if (!tmdbApiKey) {
throw new Error('缺少必要的环境变量: TMDB_API_KEY');
}
return tmdbApiKey;
}
// 导出默认配置
exports.default = getConfig();