UNPKG

kutt

Version:

Node.js & browser (TypeScript) client for Kutt url shortener

106 lines 2.24 kB
import { Domain, Health, Link, User } from "#src/api/index"; import CONFIG from "#src/config"; /** * * @see {@link https://docs.kutt.it} * @example * const kutt = new Kutt(); */ export default class Kutt { /** * * @private */ #config = { ...CONFIG }; /** * Gets default/global config. * * @param config * @example * const api = Kutt.get("api"); */ static get(config) { return CONFIG[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[config] = value; return this; } /** * Domains API. * * @see {@link https://docs.kutt.it/#tag/domains} * @example * const domains = kutt.domains(); */ domains() { return new 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 Health(this.#config); } /** * Links API. * * @see {@link https://docs.kutt.it/#tag/links} * @example * const links = kutt.links(); */ links() { return new 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 User(this.#config); } } //# sourceMappingURL=Kutt.js.map