UNPKG

kutt

Version:

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

100 lines 2.3 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const API_1 = __importDefault(require("#src/API")); /** * * @see {@link https://docs.kutt.it/#tag/links} * @example * const links = new Link(config); */ class Link extends API_1.default { /** * * @protected */ prefix = "/links"; /** * Creates a short link. * * @param link * @example * const link = await links.create({ * target: "string", * description: "string", * expire_in: "2 minutes/hours/days", * password: "string", * customurl: "string", * reuse: false, * domain: "string", * }); */ async create(link) { return this.post(link); } /** * Gets list of links. * * @param params * @param [params.skip=0] * @param [params.limit=10] * @param [params.all=false] * @example * const list = await links.list(); * @example * const list = await links.list({ * skip: 0, * limit: 10, * all: 10, * }); */ async list(params = {}) { const { skip = 0, limit = 10, all = false } = params; return this.get({ skip, limit, all, }); } /** * Deletes a link. * * @param id * @example * const message = await links.remove(link.id); */ async remove(id) { return this.delete(`/${id}`) .then(data => data.message); } /** * Gets link stats. * * @param id * @example * const stats = await links.stats(link.id); */ async stats(id) { return this.delete(`/${id}/stats`); } /** * Updates a link. * * @param id * @param link * @example * const updatedLink = await links.update(link.id, { * target: "string", * address: "string", * description: "string", * expire_in: "2 minutes/hours/days", * }); */ async update(id, link) { return this.patch(link, `/${id}`); } } exports.default = Link; //# sourceMappingURL=Link.js.map