@argos-ci/api-client
Version:
40 lines (36 loc) • 895 B
JavaScript
// src/index.ts
import createFetchClient from "openapi-fetch";
// src/debug.ts
import createDebug from "debug";
var KEY = "@argos-ci/api-client";
var debug = createDebug(KEY);
// src/schema.ts
var schema_exports = {};
// src/index.ts
function createClient(options) {
const { baseUrl } = options || {};
return createFetchClient({
baseUrl: baseUrl || "https://api.argos-ci.com/v2/",
headers: {
Authorization: `Bearer ${options.authToken}`
}
});
}
var APIError = class extends Error {
constructor(message) {
super(message);
}
};
function throwAPIError(error) {
debug("API error", error);
const detailMessage = error.details?.map((detail) => detail.message).join(", ");
throw new APIError(
detailMessage ? `${error.error}: ${detailMessage}` : error.error
);
}
export {
APIError,
schema_exports as ArgosAPISchema,
createClient,
throwAPIError
};