kutt
Version:
Node.js & browser (TypeScript) client for Kutt url shortener
112 lines • 2.54 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("#src/api/index");
const config_1 = __importDefault(require("#src/config"));
/**
*
* @see {@link https://docs.kutt.it}
* @example
* const kutt = new Kutt();
*/
class Kutt {
/**
*
* @private
*/
#config = { ...config_1.default };
/**
* Gets default/global config.
*
* @param config
* @example
* const api = Kutt.get("api");
*/
static get(config) {
return config_1.default[config];
}
/**
* Sets default/global config.
*
* @param config
* @param value
* @example
* Kutt.set("api", , "https://kutt.it/api/v2");
* @example
* Kutt.set("api", , "https://kutt.it/api/v2")
* .set("timeout", 1e4);
*/
static set(config, value) {
config_1.default[config] = value;
return this;
}
/**
* Domains API.
*
* @see {@link https://docs.kutt.it/#tag/domains}
* @example
* const domains = kutt.domains();
*/
domains() {
return new index_1.Domain(this.#config);
}
/**
* Gets instance config.
*
* @param config
* @example
* const api = kutt.get("api");
*/
get(config) {
return this.#config[config];
}
/**
* Health API.
*
* @see {@link https://docs.kutt.it/#tag/health}
* @example
* const health = kutt.health();
*/
health() {
return new index_1.Health(this.#config);
}
/**
* Links API.
*
* @see {@link https://docs.kutt.it/#tag/links}
* @example
* const links = kutt.links();
*/
links() {
return new index_1.Link(this.#config);
}
/**
* Sets instance config.
*
* @param config
* @param value
* @example
* kutt = kutt.set("api", , "https://kutt.it/api/v2");
* @example
* kutt = kutt.set("api", , "https://kutt.it/api/v2")
* .set("timeout", 1e4);
*/
set(config, value) {
this.#config[config] = value;
return this;
}
/**
* Users API.
*
* @see {@link https://docs.kutt.it/#tag/users}
* @example
* const users = kutt.users();
*/
users() {
return new index_1.User(this.#config);
}
}
exports.default = Kutt;
//# sourceMappingURL=Kutt.js.map