mongodb-rag-core
Version:
Common elements used by MongoDB Chatbot Framework components.
26 lines • 772 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnv = void 0;
function getEnv({ required, optional }) {
const env = { ...optional };
const missingRequired = [];
if (required) {
required.forEach((key) => {
env[key] = process.env[key];
if (!env[key]) {
missingRequired.push(key);
}
});
}
if (missingRequired.length > 0) {
throw new Error(`Missing required environment variables:\n${missingRequired
.map((r) => ` - ${r}`)
.join("\n")}`);
}
for (const key in optional) {
env[key] = process.env[key] ?? optional[key];
}
return env;
}
exports.getEnv = getEnv;
//# sourceMappingURL=getEnv.js.map