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",
"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",

View file

@ -11,27 +11,20 @@ export class CodeClient {
/**
* Sends the link of the code
* @return {Promise<CodeData>}
* @param {String} title
* @param {String} description
* @param {String} key
* @param {String} code
*/
public async createBin(
title: String,
description: String,
code: String
): Promise<CodeData> {
if (!title) throw new CathError("Missing 'title' property");
if (!description) throw new CathError("Missing 'description' property");
public async createBin(key: String, code: String): Promise<CodeData> {
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`);
}

View file

@ -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,
})

View file

@ -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;