INNER CODE UNIT · JavaScript
resolveApiKey
WJZ-P/gemini-skill · src/atlas-provider.js:3
function resolveApiKey(explicitApiKey) {
const apiKey = explicitApiKey || config.atlasApiKey;
if (!apiKey) {
throw new Error('缺少 ATLAS_API_KEY,请在环境变量、.env 或 .env.development 中配置');
}
return apiKey;
}
function joinUrl(baseUrl, path) {
return `${baseUrl.replace(/\/+$/, '')}${path}`;
}
async function parseJsonSafely(response) {
const raw = await response.text();
try {
return { raw, data: JSON.parse(raw) };
} catch {
return { raw, data: null };