fix on code and url client

This commit is contained in:
NK 2023-04-20 00:19:54 +01:00
parent fb056092fb
commit d9bc1bae9b
4 changed files with 12 additions and 19 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "cath", "name": "cath",
"version": "1.5.15", "version": "1.5.16",
"description": "A powerful package that can interact with Cath API", "description": "A powerful package that can interact with Cath API",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",

View file

@ -11,27 +11,20 @@ export class CodeClient {
/** /**
* Sends the link of the code * Sends the link of the code
* @return {Promise<CodeData>} * @return {Promise<CodeData>}
* @param {String} title * @param {String} key
* @param {String} description
* @param {String} code * @param {String} code
*/ */
public async createBin( public async createBin(key: String, code: String): Promise<CodeData> {
title: String, if (!key) throw new CathError("Missing 'key' property");
description: String,
code: String
): Promise<CodeData> {
if (!title) throw new CathError("Missing 'title' property");
if (!description) throw new CathError("Missing 'description' property");
if (!code) throw new CathError("Missing 'code' property"); if (!code) throw new CathError("Missing 'code' property");
const data = await axios const data = await axios
.post(`${config.code}/api/botcreate`, { .post(config.code, {
title, key,
description, value: code,
code,
}) })
.then(res => res.data); .then(res => res.data);
if (data?.name) { if (data?.url) {
return data?.name; return data?.url;
} else { } else {
throw new CathError(`Code already exist`); throw new CathError(`Code already exist`);
} }

View file

@ -21,7 +21,7 @@ export class URLClient {
if (!shortName) throw new CathError("Missing 'shortName' property"); if (!shortName) throw new CathError("Missing 'shortName' property");
if (!targetURL) throw new CathError("Missing 'targetURL' property"); if (!targetURL) throw new CathError("Missing 'targetURL' property");
const data = await axios const data = await axios
.post(`${config.url}/api/create`, { .post(`${config.url}`, {
shortUrl: shortName, shortUrl: shortName,
fullUrl: targetURL, fullUrl: targetURL,
}) })

View file

@ -48,8 +48,8 @@ export { round } from "./functions/round";
const config: ConfigURLS = { const config: ConfigURLS = {
api: "https://api.night0721.me", api: "https://api.night0721.me",
code: "https://code.night0721.me", code: "https://cdn.night0721.me/api/paste",
url: "https://url.night0721.me", url: "https://cdn.night0721.me/api/url",
}; };
export default config; export default config;