UNPKG

kutt

Version:

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

78 lines 1.47 kB
export var METHOD; (function (METHOD) { METHOD["GET"] = "GET"; METHOD["POST"] = "POST"; METHOD["PATCH"] = "PATCH"; METHOD["DELETE"] = "DELETE"; })(METHOD || (METHOD = {})); /** * */ export default 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}`; } } //# sourceMappingURL=API.js.map