UNPKG

kutt

Version:

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

82 lines 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.METHOD = void 0; var METHOD; (function (METHOD) { METHOD["GET"] = "GET"; METHOD["POST"] = "POST"; METHOD["PATCH"] = "PATCH"; METHOD["DELETE"] = "DELETE"; })(METHOD = exports.METHOD || (exports.METHOD = {})); /** * */ class API { config; /** * * @param config */ constructor(config) { this.config = config; } /** * * @param url * @protected */ async delete(url) { return this.request({ method: METHOD.DELETE, url, }); } async get(params, url) { if (typeof params === "string") { url = params; // eslint-disable-next-line no-undefined params = undefined; } return this.request({ url, params, }); } /** * * @param data * @param url * @protected */ async patch(data, url) { return this.request({ method: METHOD.PATCH, body: data, url, }); } /** * * @param data * @param url * @protected */ async post(data, url) { return this.request({ method: METHOD.POST, body: data, url, }); } /** * * @param url * @protected */ url(url) { const { config: { api }, prefix } = this; return `${api}${prefix}${url}`; } } exports.default = API; //# sourceMappingURL=API.js.map