From d9bc1bae9bbedb1cafc8984b68d45ccc69621802 Mon Sep 17 00:00:00 2001 From: NK Date: Thu, 20 Apr 2023 00:19:54 +0100 Subject: [PATCH] fix on code and url client --- package.json | 2 +- src/CodeClient/codeclient.ts | 23 ++++++++--------------- src/URLClient/urlclient.ts | 2 +- src/index.ts | 4 ++-- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index b3c1e02..3d73c0c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cath", - "version": "1.5.15", + "version": "1.5.16", "description": "A powerful package that can interact with Cath API", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/CodeClient/codeclient.ts b/src/CodeClient/codeclient.ts index 7583e04..ee0db2d 100644 --- a/src/CodeClient/codeclient.ts +++ b/src/CodeClient/codeclient.ts @@ -11,27 +11,20 @@ export class CodeClient { /** * Sends the link of the code * @return {Promise} - * @param {String} title - * @param {String} description + * @param {String} key * @param {String} code */ - public async createBin( - title: String, - description: String, - code: String - ): Promise { - if (!title) throw new CathError("Missing 'title' property"); - if (!description) throw new CathError("Missing 'description' property"); + public async createBin(key: String, code: String): Promise { + if (!key) throw new CathError("Missing 'key' property"); if (!code) throw new CathError("Missing 'code' property"); const data = await axios - .post(`${config.code}/api/botcreate`, { - title, - description, - code, + .post(config.code, { + key, + value: code, }) .then(res => res.data); - if (data?.name) { - return data?.name; + if (data?.url) { + return data?.url; } else { throw new CathError(`Code already exist`); } diff --git a/src/URLClient/urlclient.ts b/src/URLClient/urlclient.ts index df9cb53..d71976c 100644 --- a/src/URLClient/urlclient.ts +++ b/src/URLClient/urlclient.ts @@ -21,7 +21,7 @@ export class URLClient { if (!shortName) throw new CathError("Missing 'shortName' property"); if (!targetURL) throw new CathError("Missing 'targetURL' property"); const data = await axios - .post(`${config.url}/api/create`, { + .post(`${config.url}`, { shortUrl: shortName, fullUrl: targetURL, }) diff --git a/src/index.ts b/src/index.ts index 8d05995..fe89d65 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,8 +48,8 @@ export { round } from "./functions/round"; const config: ConfigURLS = { api: "https://api.night0721.me", - code: "https://code.night0721.me", - url: "https://url.night0721.me", + code: "https://cdn.night0721.me/api/paste", + url: "https://cdn.night0721.me/api/url", }; export default config;