@banked/node
Version:
Node.js library for the Banked API
40 lines (31 loc) • 873 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getClient = exports.bootstrapClient = void 0;
var _axios = _interopRequireDefault(require("axios"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
let instance;
const bootstrapClient = keys => {
instance = _axios.default.create({
baseURL: "https://api.banked.com/v2",
timeout: 3000
});
instance.interceptors.request.use(config => {
if (keys.access_token) {
config.headers.Authorization = `Bearer ${keys.access_token}`;
} else {
config.auth = {
username: keys.api_key,
password: keys.secret_key
};
}
return config;
});
return instance;
};
exports.bootstrapClient = bootstrapClient;
const getClient = () => {
return instance;
};
exports.getClient = getClient;