ayiin 1.0.24 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,28 +1,28 @@
1
- # Library For AyiinXd
2
-
3
- ## Installation
4
-
5
- This is a [Node.js](https://nodejs.org/en/) module available through the
6
- [npm registry](https://www.npmjs.com/).
7
-
8
- Before installing, [download and install Node.js](https://nodejs.org/en/download/).
9
- Node.js 0.10 or higher is required.
10
-
11
- If this is a brand new project, make sure to create a `package.json` first with
12
- the [`npm init` command](https://docs.npmjs.com/creating-a-package-json-file).
13
-
14
- Installation is done using the
15
- [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
16
-
17
- ```console
18
- $ npm install ayiin
19
- ```
20
-
21
- ## Features
22
-
23
- * This is for me to learn javascript
24
-
25
-
26
- ## License
27
-
28
- [MIT](LICENSE)
1
+ # Library For AyiinXd
2
+
3
+ ## Installation
4
+
5
+ This is a [Node.js](https://nodejs.org/en/) module available through the
6
+ [npm registry](https://www.npmjs.com/).
7
+
8
+ Before installing, [download and install Node.js](https://nodejs.org/en/download/).
9
+ Node.js 0.10 or higher is required.
10
+
11
+ If this is a brand new project, make sure to create a `package.json` first with
12
+ the [`npm init` command](https://docs.npmjs.com/creating-a-package-json-file).
13
+
14
+ Installation is done using the
15
+ [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
16
+
17
+ ```console
18
+ $ npm install ayiin
19
+ ```
20
+
21
+ ## Features
22
+
23
+ * This is for me to learn javascript
24
+
25
+
26
+ ## License
27
+
28
+ [MIT](LICENSE)
package/ayiin/index.d.ts CHANGED
@@ -1,16 +1,7 @@
1
- import Base from "./base";
2
- import { Provider } from "./types/provider";
3
- import { Response } from "./types/response";
4
- import { Video } from "./types/video";
5
- import { Videos } from "./types/videos";
6
- declare class Ayiin extends Base {
1
+ import Methods from "./methods";
2
+ import { Options } from "./types/options";
3
+ declare class Ayiin extends Methods {
7
4
  version: string;
8
- constructor(apiToken: string);
9
- download: (url: string, fileName: string) => Promise<string>;
10
- getContent: (provider: Provider, id: string) => Promise<Video>;
11
- randomContent: (provider: Provider) => Promise<Video>;
12
- relatedContent: (provider: Provider, id: string) => Promise<Array<Videos>>;
13
- searchContent: (provider: Provider, query: string, page?: number) => Promise<Array<Videos>>;
14
- userInfo: () => Promise<Response>;
5
+ constructor(options?: Options);
15
6
  }
16
7
  export default Ayiin;
package/ayiin/index.js CHANGED
@@ -1,85 +1,14 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const fs_1 = __importDefault(require("fs"));
16
- const path_1 = __importDefault(require("path"));
17
- const base_1 = __importDefault(require("./base"));
18
6
  const package_json_1 = __importDefault(require("../package.json"));
19
- class Ayiin extends base_1.default {
20
- constructor(apiToken) {
21
- super(apiToken);
7
+ const methods_1 = __importDefault(require("./methods"));
8
+ class Ayiin extends methods_1.default {
9
+ constructor(options) {
10
+ super(options);
22
11
  this.version = package_json_1.default.version;
23
- this.download = (url, fileName) => __awaiter(this, void 0, void 0, function* () {
24
- const res = yield this.get(url, "stream");
25
- const writeStream = fs_1.default.createWriteStream(path_1.default.join(`${this.basePath}/${fileName}.mp4`), res.response.data);
26
- return new Promise((resolve, reject) => {
27
- res.response.data.pipe(writeStream);
28
- writeStream.on("error", (err) => {
29
- console.log(err);
30
- reject(err);
31
- });
32
- writeStream.on("finish", () => {
33
- writeStream.close();
34
- return resolve(path_1.default.join(`${this.basePath}/${fileName}.mp4`));
35
- });
36
- });
37
- });
38
- this.getContent = (provider, id) => __awaiter(this, void 0, void 0, function* () {
39
- const res = yield this.post(provider, `detail?id=${id}`);
40
- if (res.success) {
41
- return res.result;
42
- }
43
- else {
44
- throw new Error(res.message);
45
- }
46
- });
47
- this.randomContent = (provider) => __awaiter(this, void 0, void 0, function* () {
48
- const res = yield this.post(provider, "random");
49
- if (res.success) {
50
- return res.result;
51
- }
52
- else {
53
- throw new Error(res.message);
54
- }
55
- });
56
- this.relatedContent = (provider, id) => __awaiter(this, void 0, void 0, function* () {
57
- const res = yield this.post(provider, `related?id=${id}`);
58
- if (res.success) {
59
- return res.result.data;
60
- }
61
- else {
62
- throw new Error(res.message);
63
- }
64
- });
65
- this.searchContent = (provider, query, page) => __awaiter(this, void 0, void 0, function* () {
66
- const res = yield this.post(provider, `search?key=${query}${page ? `&page=${page}` : ""}`);
67
- if (res.success) {
68
- return res.result.data;
69
- }
70
- else {
71
- throw new Error(res.message);
72
- }
73
- });
74
- this.userInfo = () => __awaiter(this, void 0, void 0, function* () {
75
- const res = yield this.get("/auth");
76
- if (res.success) {
77
- return res;
78
- }
79
- else {
80
- throw new Error(res.message);
81
- }
82
- });
83
12
  }
84
13
  ;
85
14
  }
@@ -0,0 +1,38 @@
1
+ import crypto from 'crypto';
2
+ declare class Crypt {
3
+ /**
4
+ * Performs Base encryption and decryption.
5
+ * @param {string | Buffer} input - The input data to be encrypted or decrypted.
6
+ * @param {string} key - The encryption/decryption key.
7
+ * @returns {Buffer} - The encrypted or decrypted data as a Buffer.
8
+ */
9
+ private baseCrypt;
10
+ /**
11
+ * Encrypts a plaintext message using the given key.
12
+ * @param {string} text - The plaintext message to be encrypted.
13
+ * @param {string} key - The encryption key.
14
+ * @returns {string} - The encrypted data in Hex format.
15
+ */
16
+ encrypt: (text: string, key: string, bufferEncoding?: BufferEncoding) => string;
17
+ /**
18
+ * Decrypts an encrypted message using the given key.
19
+ * @param {string} encrypted - The encrypted data in Hex format.
20
+ * @param {string} key - The decryption key.
21
+ * @returns {string} - The decrypted plaintext message.
22
+ */
23
+ decrypt: (encrypted: string, key: string, bufferEncoding?: BufferEncoding) => string;
24
+ /**
25
+ * Converts a Hex string to its corresponding ASCII representation.
26
+ * @param {string} hexString - The Hex string to be converted.
27
+ * @returns {string} - The ASCII representation of the Hex string.
28
+ */
29
+ hexToAscii: (hexString: string) => string;
30
+ /**
31
+ * Converts an ASCII string to its corresponding Hex representation.
32
+ * @param {string} asciiString - The ASCII string to be converted.
33
+ * @returns {string} - The Hex representation of the ASCII string.
34
+ */
35
+ asciiToHex: (asciiString: string) => string;
36
+ md5: (data: string, encoding: crypto.BinaryToTextEncoding) => string;
37
+ }
38
+ export default Crypt;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const crypto_1 = __importDefault(require("crypto"));
7
+ class Crypt {
8
+ constructor() {
9
+ /**
10
+ * Performs Base encryption and decryption.
11
+ * @param {string | Buffer} input - The input data to be encrypted or decrypted.
12
+ * @param {string} key - The encryption/decryption key.
13
+ * @returns {Buffer} - The encrypted or decrypted data as a Buffer.
14
+ */
15
+ this.baseCrypt = (input, key) => {
16
+ const inputBuffer = Buffer.from(input, 'ascii');
17
+ const keyBuffer = Buffer.from(key, 'ascii');
18
+ const resultBuffer = Buffer.alloc(inputBuffer.length);
19
+ for (let i = 0; i < inputBuffer.length; i++) {
20
+ resultBuffer[i] = inputBuffer[i] ^ keyBuffer[i % keyBuffer.length];
21
+ }
22
+ return resultBuffer;
23
+ };
24
+ /**
25
+ * Encrypts a plaintext message using the given key.
26
+ * @param {string} text - The plaintext message to be encrypted.
27
+ * @param {string} key - The encryption key.
28
+ * @returns {string} - The encrypted data in Hex format.
29
+ */
30
+ this.encrypt = (text, key, bufferEncoding) => {
31
+ if (!bufferEncoding)
32
+ bufferEncoding = 'base64';
33
+ const encryptedBuffer = this.baseCrypt(text, key);
34
+ return encryptedBuffer.toString(bufferEncoding);
35
+ };
36
+ /**
37
+ * Decrypts an encrypted message using the given key.
38
+ * @param {string} encrypted - The encrypted data in Hex format.
39
+ * @param {string} key - The decryption key.
40
+ * @returns {string} - The decrypted plaintext message.
41
+ */
42
+ this.decrypt = (encrypted, key, bufferEncoding) => {
43
+ if (!bufferEncoding)
44
+ bufferEncoding = 'base64';
45
+ const encryptedBuffer = Buffer.from(encrypted, bufferEncoding);
46
+ const decryptedBuffer = this.baseCrypt(encryptedBuffer, key);
47
+ return decryptedBuffer.toString('ascii');
48
+ };
49
+ /**
50
+ * Converts a Hex string to its corresponding ASCII representation.
51
+ * @param {string} hexString - The Hex string to be converted.
52
+ * @returns {string} - The ASCII representation of the Hex string.
53
+ */
54
+ this.hexToAscii = (hexString) => {
55
+ const hexBuffer = Buffer.from(hexString, 'hex');
56
+ return hexBuffer.toString('ascii');
57
+ };
58
+ /**
59
+ * Converts an ASCII string to its corresponding Hex representation.
60
+ * @param {string} asciiString - The ASCII string to be converted.
61
+ * @returns {string} - The Hex representation of the ASCII string.
62
+ */
63
+ this.asciiToHex = (asciiString) => {
64
+ const asciiBuffer = Buffer.from(asciiString, 'ascii');
65
+ return asciiBuffer.toString('hex');
66
+ };
67
+ this.md5 = (data, encoding) => {
68
+ if (!encoding)
69
+ encoding = 'hex';
70
+ let hasho = crypto_1.default
71
+ .createHash("md5")
72
+ .update(data)
73
+ .digest(encoding);
74
+ return hasho;
75
+ };
76
+ }
77
+ }
78
+ ;
79
+ exports.default = Crypt;
@@ -0,0 +1,25 @@
1
+ import { BinaryToTextEncoding } from "crypto";
2
+ import Mail from 'nodemailer/lib/mailer';
3
+ import Crypt from "./crypt";
4
+ import Tools from "./tools";
5
+ import Mailer from "./mailer";
6
+ import { Options } from "../types/options";
7
+ declare class BaseMethods<C extends Crypt, M extends Mailer, T extends Tools> {
8
+ crypt: C;
9
+ mailer: M;
10
+ tools: T;
11
+ constructor(options?: Options);
12
+ asciiToHex: (asciiString: string) => string;
13
+ hexToAscii: (hexString: string) => string;
14
+ encrypt: (text: string, key: string, bufferEncoding?: BufferEncoding) => string;
15
+ decrypt: (text: string, key: string, bufferEncoding?: BufferEncoding) => string;
16
+ md5: (data: string, encoding: BinaryToTextEncoding) => string;
17
+ sendMail: (options: Mail.Options) => Promise<{
18
+ success: boolean;
19
+ message: string;
20
+ }>;
21
+ randomString: (length: number) => string;
22
+ }
23
+ declare class Methods extends BaseMethods<Crypt, Mailer, Tools> {
24
+ }
25
+ export default Methods;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const crypt_1 = __importDefault(require("./crypt"));
16
+ const tools_1 = __importDefault(require("./tools"));
17
+ const mailer_1 = __importDefault(require("./mailer"));
18
+ class BaseMethods {
19
+ constructor(options) {
20
+ this.asciiToHex = (asciiString) => this.crypt.asciiToHex(asciiString);
21
+ this.hexToAscii = (hexString) => this.crypt.hexToAscii(hexString);
22
+ this.encrypt = (text, key, bufferEncoding) => this.crypt.encrypt(text, key, bufferEncoding);
23
+ this.decrypt = (text, key, bufferEncoding) => this.crypt.decrypt(text, key, bufferEncoding);
24
+ this.md5 = (data, encoding) => this.crypt.md5(data, encoding);
25
+ this.sendMail = (options) => __awaiter(this, void 0, void 0, function* () { return yield this.mailer.sendMail(options); });
26
+ this.randomString = (length) => this.tools.randomString(length);
27
+ this.crypt = new crypt_1.default();
28
+ this.mailer = new mailer_1.default(options);
29
+ this.tools = new tools_1.default();
30
+ }
31
+ }
32
+ ;
33
+ class Methods extends BaseMethods {
34
+ }
35
+ exports.default = Methods;
@@ -0,0 +1,14 @@
1
+ import nodemailer from 'nodemailer';
2
+ import Mail from 'nodemailer/lib/mailer';
3
+ import SMTPTransport from 'nodemailer/lib/smtp-transport';
4
+ import { Options } from '../types/options';
5
+ type ResponseMailer = {
6
+ success: boolean;
7
+ message: string;
8
+ };
9
+ declare class Mailer {
10
+ client?: nodemailer.Transporter<SMTPTransport.SentMessageInfo, SMTPTransport.Options>;
11
+ constructor(opts?: Options);
12
+ sendMail: (options: Mail.Options) => Promise<ResponseMailer>;
13
+ }
14
+ export default Mailer;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const nodemailer_1 = __importDefault(require("nodemailer"));
16
+ class Mailer {
17
+ constructor(opts) {
18
+ this.sendMail = (options) => __awaiter(this, void 0, void 0, function* () {
19
+ return yield new Promise((resolve, reject) => {
20
+ if (!this.client) {
21
+ throw new Error('Mailer is not initialized, Set Your Email and Password first');
22
+ }
23
+ this.client.sendMail(options, (err) => {
24
+ if (err) {
25
+ return reject({
26
+ success: false,
27
+ message: err.message
28
+ });
29
+ }
30
+ else {
31
+ return resolve({
32
+ success: true,
33
+ message: "Email sent successfully"
34
+ });
35
+ }
36
+ });
37
+ });
38
+ });
39
+ if (opts !== undefined) {
40
+ this.client = nodemailer_1.default.createTransport({
41
+ service: 'Gmail', // Use your email service
42
+ auth: {
43
+ user: opts.email, // Your email address
44
+ pass: opts.password, // Your password
45
+ },
46
+ });
47
+ }
48
+ else {
49
+ this.client = undefined;
50
+ }
51
+ }
52
+ }
53
+ ;
54
+ exports.default = Mailer;
@@ -0,0 +1,10 @@
1
+ declare class Tools {
2
+ /**
3
+ * Generate a random string
4
+ * @returns {string}
5
+ * @memberof Tools
6
+ * @param {number} length
7
+ * */
8
+ randomString: (length: number) => string;
9
+ }
10
+ export default Tools;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Tools {
4
+ constructor() {
5
+ /**
6
+ * Generate a random string
7
+ * @returns {string}
8
+ * @memberof Tools
9
+ * @param {number} length
10
+ * */
11
+ this.randomString = (length) => {
12
+ const alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
13
+ let random = '';
14
+ for (let i = 0; i < length; i++) {
15
+ random += alphabet[Math.floor(Math.random() * alphabet.length)];
16
+ }
17
+ return random;
18
+ };
19
+ }
20
+ }
21
+ ;
22
+ exports.default = Tools;
@@ -0,0 +1,4 @@
1
+ export type Options = {
2
+ email?: string;
3
+ password?: string;
4
+ };
@@ -0,0 +1,5 @@
1
+ export type SendMail = {
2
+ to: string;
3
+ subject: string;
4
+ htmlText: string;
5
+ };
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- ;
package/package.json CHANGED
@@ -1,15 +1,28 @@
1
- {
2
- "name": "ayiin",
3
- "version": "1.0.24",
4
- "description": "Library Pribadi Yang Gak Ada Isinya",
5
- "author": "AyiinXd",
6
- "license": "MIT",
7
- "main": "ayiin/index.js",
8
- "dependencies": {
9
- "axios": "^1.7.5"
10
- },
11
- "devDependencies": {
12
- "@types/node": "^22.5.0",
13
- "dotenv": "^16.4.5"
14
- }
1
+ {
2
+ "name": "ayiin",
3
+ "version": "2.0.0",
4
+ "description": "Library Pribadi Yang Gak Ada Isinya",
5
+ "main": "ayiin/index.js",
6
+ "scripts": {
7
+ "build": "yarn tsc"
8
+ },
9
+ "repository": "https://github.com/AyiinXd/midtrans",
10
+ "author": {
11
+ "name": "AyiinXd",
12
+ "url": "https://github.com/AyiinXd"
13
+ },
14
+ "keywords": [
15
+ "ayiin"
16
+ ],
17
+ "license": "GPL-3.0-only",
18
+ "dependencies": {
19
+ "@types/node": "^22.7.4",
20
+ "@types/nodemailer": "^6.4.17",
21
+ "axios": "^1.7.7",
22
+ "nodemailer": "^6.9.16"
23
+ },
24
+ "devDependencies": {
25
+ "ts-node": "^10.9.2",
26
+ "typescript": "^5.6.2"
27
+ }
15
28
  }
package/tsconfig.json CHANGED
@@ -1,19 +1,19 @@
1
- {
2
- "compilerOptions": {
3
- "incremental": true,
4
- "target": "es2016",
5
- "module": "commonjs",
6
- "rootDir": "src",
7
- "resolveJsonModule": true,
8
- "declaration": true,
9
- "outDir": "./ayiin",
10
- "esModuleInterop": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "strict": true,
13
- "alwaysStrict": true,
14
- "skipLibCheck": true
15
- },
16
- "include": [
17
- "src/**/*"
18
- ]
1
+ {
2
+ "compilerOptions": {
3
+ "incremental": true,
4
+ "target": "es2016",
5
+ "module": "commonjs",
6
+ "rootDir": "src",
7
+ "resolveJsonModule": true,
8
+ "declaration": true,
9
+ "outDir": "./ayiin",
10
+ "esModuleInterop": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "strict": true,
13
+ "alwaysStrict": true,
14
+ "skipLibCheck": true
15
+ },
16
+ "include": [
17
+ "src/**/*"
18
+ ]
19
19
  }
package/ayiin/base.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { AxiosInstance } from "axios";
2
- import { Response, ResponseAxios } from "./types/response";
3
- import { Provider } from "./types/provider";
4
- type TypeField = "json" | "stream";
5
- declare class Base {
6
- api: AxiosInstance;
7
- baseUrl: string;
8
- basePath: string;
9
- constructor(apiToken: string, basePath?: string);
10
- post: (provider: Provider, url: string) => Promise<Response>;
11
- get: (url: string, type?: TypeField) => Promise<ResponseAxios>;
12
- validatePath: (autoClean?: boolean) => void;
13
- }
14
- export default Base;
package/ayiin/base.js DELETED
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const fs_1 = __importDefault(require("fs"));
16
- const path_1 = __importDefault(require("path"));
17
- const axios_1 = __importDefault(require("axios"));
18
- class Base {
19
- constructor(apiToken, basePath) {
20
- this.baseUrl = "https://ayiinhub.vercel.app/api";
21
- this.post = (provider, url) => __awaiter(this, void 0, void 0, function* () {
22
- const res = yield this.api.post(`${provider}/${url}`);
23
- const data = res.data;
24
- if (data.success) {
25
- return data;
26
- }
27
- else {
28
- throw new Error(data.message);
29
- }
30
- });
31
- this.get = (url, type) => __awaiter(this, void 0, void 0, function* () {
32
- if (type && type === "stream") {
33
- const res = yield this.api.get(url, {
34
- responseType: "stream"
35
- });
36
- const response = {
37
- success: true,
38
- message: "success",
39
- response: res
40
- };
41
- return response;
42
- }
43
- else {
44
- const res = yield this.api.get(url);
45
- const data = res.data;
46
- if (data.success) {
47
- return data;
48
- }
49
- else {
50
- throw new Error(data.message);
51
- }
52
- }
53
- });
54
- this.validatePath = (autoClean) => {
55
- if (!fs_1.default.existsSync(this.basePath)) {
56
- fs_1.default.mkdirSync(this.basePath);
57
- }
58
- ;
59
- if (autoClean) {
60
- const files = fs_1.default.readdirSync(this.basePath);
61
- files.forEach(file => {
62
- fs_1.default.unlinkSync(path_1.default.join(this.basePath, file));
63
- });
64
- }
65
- };
66
- this.api = axios_1.default.create({
67
- baseURL: `${this.baseUrl}`,
68
- headers: {
69
- "Authorization": `Bearer ${apiToken}`,
70
- "Content-Type": "application/json",
71
- }
72
- });
73
- this.basePath = basePath !== null && basePath !== void 0 ? basePath : "downloads";
74
- }
75
- }
76
- ;
77
- exports.default = Base;
@@ -1 +0,0 @@
1
- export type Provider = "xnxx" | "xvideos";
@@ -1,12 +0,0 @@
1
- import { AxiosResponse } from "axios";
2
- export interface Response {
3
- success: boolean;
4
- message: string;
5
- result?: any;
6
- }
7
- export interface ResponseAxios<AR extends AxiosResponse = AxiosResponse<any, any>> {
8
- response: AR;
9
- success: boolean;
10
- message: string;
11
- result?: any;
12
- }