26 lines
682 B
JavaScript
26 lines
682 B
JavaScript
const { RRClient } = require("./lib/index.cjs");
|
|
|
|
/**
|
|
* Build an RR client using env credentials.
|
|
* @param {{logger?: {debug?:Function,info?:Function,warn?:Function,error?:Function}}} opts
|
|
*/
|
|
function makeRRClient({ logger } = {}) {
|
|
const baseUrl = process.env.RR_BASE_URL;
|
|
const username = process.env.RR_USERNAME;
|
|
const password = process.env.RR_PASSWORD;
|
|
|
|
if (!baseUrl || !username || !password) {
|
|
throw new Error("RR creds missing (RR_BASE_URL, RR_USERNAME, RR_PASSWORD).");
|
|
}
|
|
|
|
return new RRClient({
|
|
baseUrl,
|
|
username,
|
|
password,
|
|
logger
|
|
// retries: { max: 3 }, // optional: override retry policy
|
|
});
|
|
}
|
|
|
|
module.exports = { makeRRClient };
|