@codex-storage/sdk-js
Version:
Codex SDK to interact with the Codex decentralized storage network.
58 lines (56 loc) • 1.46 kB
JavaScript
import { Api } from './chunk-JUEFSJIF.mjs';
import { Fetch, FetchAuthBuilder } from './chunk-2VOCE3TZ.mjs';
import { CodexError, CodexValibotIssuesMap } from './chunk-MVZZ6JVF.mjs';
import * as v from 'valibot';
var CodexLogLevelInput = v.picklist([
"TRACE",
"DEBUG",
"INFO",
"NOTICE",
"WARN",
"ERROR",
"FATAL"
]);
var CodexDebug = class {
url;
auth = {};
constructor(url, options) {
this.url = url;
if (options == null ? void 0 : options.auth) {
this.auth = options.auth;
}
}
/**
* Set log level at run time
*/
async setLogLevel(level) {
const result = v.safeParse(CodexLogLevelInput, level);
if (!result.success) {
return Promise.resolve({
error: true,
data: new CodexError("Cannot validate the input", {
errors: CodexValibotIssuesMap(result.issues)
})
});
}
const url = this.url + Api.config.prefix + "/debug/chronicles/loglevel?level=" + level;
return Fetch.safeText(url, {
method: "POST",
headers: FetchAuthBuilder.build(this.auth),
body: ""
});
}
/**
* Gets node information
*/
info() {
const url = this.url + Api.config.prefix + `/debug/info`;
return Fetch.safeJson(url, {
method: "GET",
headers: FetchAuthBuilder.build(this.auth)
});
}
};
export { CodexDebug, CodexLogLevelInput };
//# sourceMappingURL=chunk-OUB34QMD.mjs.map
//# sourceMappingURL=chunk-OUB34QMD.mjs.map