@xstbot/cloudku 1.0.2 → 1.0.3
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 +64 -90
- package/dist/esm/index.js +30 -70
- package/dist/index.js +34 -81
- package/package.json +56 -67
- package/dist/esm/index.js.map +0 -1
- package/dist/index.d.ts +0 -62
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
# @xstbot/cloudku
|
|
2
2
|
|
|
3
|
-
> **CloudKu Official SDK**
|
|
3
|
+
> **CloudKu Official SDK** Solusi integrasi CDN yang cepat, aman, dan dirancang khusus untuk pengembang modern.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@xstbot/cloudku)
|
|
6
6
|
[](https://www.npmjs.com/package/@xstbot/cloudku)
|
|
7
|
-
[](https://www.typescriptlang.org/)
|
|
8
7
|
[]()
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
¦ NPM Package : https://www.npmjs.com/package/@xstbot/cloudku
|
|
10
|
+
– Dokumentasi : https://cloudku.sbs/docs
|
|
12
11
|
|
|
13
12
|
---
|
|
14
13
|
|
|
15
|
-
##
|
|
14
|
+
## ‹ Daftar Isi
|
|
16
15
|
|
|
17
16
|
- [Tentang](#tentang)
|
|
18
17
|
- [Instalasi](#instalasi)
|
|
19
18
|
- [Penggunaan](#penggunaan)
|
|
20
19
|
- [JavaScript (CommonJS)](#javascript-commonjs)
|
|
21
|
-
- [
|
|
20
|
+
- [JavaScript (ES Module)](#javascript-es-module)
|
|
22
21
|
- [API Reference](#api-reference)
|
|
23
22
|
- [Response Schema](#response-schema)
|
|
24
23
|
- [Error Handling](#error-handling)
|
|
@@ -26,159 +25,134 @@
|
|
|
26
25
|
|
|
27
26
|
---
|
|
28
27
|
|
|
29
|
-
##
|
|
28
|
+
## Tentang
|
|
30
29
|
|
|
31
|
-
`@xstbot/cloudku` adalah SDK resmi dari **CloudKu CDN** yang memungkinkan pengembang mengunggah file ke jaringan CDN secara mudah dan cepat. Library ini mendukung **JavaScript** (CJS
|
|
30
|
+
`@xstbot/cloudku` adalah SDK resmi dari **CloudKu CDN** yang memungkinkan pengembang mengunggah file ke jaringan CDN secara mudah dan cepat. Library ini mendukung **JavaScript** dalam format **CommonJS (CJS)** maupun **ES Module (ESM)**, sehingga kompatibel dengan berbagai environment Node.js modern.
|
|
32
31
|
|
|
33
32
|
---
|
|
34
33
|
|
|
35
|
-
##
|
|
34
|
+
## Instalasi
|
|
36
35
|
|
|
36
|
+
```bash
|
|
37
37
|
npm install @xstbot/cloudku
|
|
38
38
|
# atau
|
|
39
39
|
yarn add @xstbot/cloudku
|
|
40
|
+
```
|
|
40
41
|
|
|
41
42
|
---
|
|
42
43
|
|
|
43
|
-
##
|
|
44
|
+
## – Penggunaan
|
|
44
45
|
|
|
45
46
|
### JavaScript (CommonJS)
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
```js
|
|
49
|
+
const { CloudKu } = require('@xstbot/cloudku');
|
|
48
50
|
const fs = require('fs');
|
|
49
51
|
|
|
50
52
|
const buffer = fs.readFileSync('./photo.jpg');
|
|
51
53
|
|
|
52
|
-
// Menggunakan Class (dengan konfigurasi)
|
|
53
|
-
const client = new CloudKu({ timeout: 60_000 });
|
|
54
|
-
|
|
55
54
|
async function handleUpload() {
|
|
56
55
|
try {
|
|
57
|
-
const result = await
|
|
56
|
+
const result = await CloudKu(buffer, 'photo.jpg');
|
|
58
57
|
if (result.status === 'success') {
|
|
59
|
-
console.log('
|
|
58
|
+
console.log('File berhasil diunggah:', result.url);
|
|
60
59
|
} else {
|
|
61
|
-
console.error('
|
|
60
|
+
console.error('API Error:', result.message);
|
|
62
61
|
}
|
|
63
62
|
} catch (err) {
|
|
64
|
-
console.error('
|
|
63
|
+
console.error('System Error:', err.message);
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const result = await uploadFile(buffer, 'photo.jpg');
|
|
71
|
-
console.log(result);
|
|
72
|
-
}
|
|
67
|
+
handleUpload();
|
|
68
|
+
```
|
|
73
69
|
|
|
74
70
|
---
|
|
75
71
|
|
|
76
|
-
###
|
|
72
|
+
### JavaScript (ES Module)
|
|
77
73
|
|
|
78
|
-
|
|
79
|
-
import
|
|
80
|
-
import
|
|
81
|
-
|
|
82
|
-
const buffer = fs.readFileSync('./photo.jpg');
|
|
74
|
+
```js
|
|
75
|
+
import { CloudKu } from '@xstbot/cloudku';
|
|
76
|
+
import { readFileSync } from 'fs';
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
const options: CloudKuOptions = { timeout: 60_000 };
|
|
86
|
-
const client = new CloudKu(options);
|
|
78
|
+
const buffer = readFileSync('./photo.jpg');
|
|
87
79
|
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
console.log(
|
|
80
|
+
const handleUpload = async () => {
|
|
81
|
+
const result = await CloudKu(buffer, 'photo.jpg');
|
|
82
|
+
if (result.status === 'success') {
|
|
83
|
+
console.log(`File live at: ${result.url}`);
|
|
84
|
+
} else {
|
|
85
|
+
console.error('Upload gagal:', result.message);
|
|
92
86
|
}
|
|
93
87
|
};
|
|
94
88
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const response = await uploadFile(buffer, 'photo.jpg');
|
|
98
|
-
console.log(response);
|
|
99
|
-
};
|
|
89
|
+
handleUpload();
|
|
90
|
+
```
|
|
100
91
|
|
|
101
92
|
---
|
|
102
93
|
|
|
103
|
-
##
|
|
104
|
-
|
|
105
|
-
### uploadFile(fileBuffer, fileName, options?)
|
|
94
|
+
## API Reference
|
|
106
95
|
|
|
107
|
-
|
|
96
|
+
### CloudKu(fileBuffer, fileName)
|
|
108
97
|
|
|
109
|
-
|
|
110
|
-
|-------------------|----------|----------|-------------------------------------|
|
|
111
|
-
| fileBuffer | Buffer | YES | Isi file sebagai Node.js Buffer |
|
|
112
|
-
| fileName | string | YES | Nama file beserta ekstensi |
|
|
113
|
-
| options.apiUrl | string | NO | Custom API URL |
|
|
114
|
-
| options.timeout | number | NO | Timeout dalam ms (default: 30000) |
|
|
115
|
-
|
|
116
|
-
---
|
|
98
|
+
Fungsi utama untuk upload file ke CloudKu CDN.
|
|
117
99
|
|
|
118
|
-
|
|
100
|
+
| Parameter | Type | Required | Description |
|
|
101
|
+
|--------------|----------|----------|---------------------------------|
|
|
102
|
+
| fileBuffer | Buffer | YES | Isi file sebagai Node.js Buffer |
|
|
103
|
+
| fileName | string | YES | Nama file beserta ekstensinya |
|
|
119
104
|
|
|
120
|
-
|
|
105
|
+
**Returns:** `Promise<Object>` Response dari CDN.
|
|
121
106
|
|
|
122
|
-
|
|
123
|
-
|-----------|----------|-----------------------------------|---------------------|
|
|
124
|
-
| apiUrl | string | https://cloudku.sbs/cdn/api.php | Custom API endpoint |
|
|
125
|
-
| timeout | number | 30000 | Timeout dalam ms |
|
|
107
|
+
---
|
|
126
108
|
|
|
127
|
-
|
|
109
|
+
## Response Schema
|
|
128
110
|
|
|
129
|
-
|
|
|
130
|
-
|
|
131
|
-
|
|
|
132
|
-
|
|
|
111
|
+
| Property | Type | Description |
|
|
112
|
+
|------------|-------------------------|-----------------------------------------------|
|
|
113
|
+
| status | "success" atau "error" | Status hasil operasi |
|
|
114
|
+
| message | string | Detail pesan atau informasi error |
|
|
115
|
+
| url | string atau undefined | URL publik file (hanya tersedia jika success) |
|
|
133
116
|
|
|
134
117
|
---
|
|
135
118
|
|
|
136
|
-
##
|
|
137
|
-
|
|
138
|
-
| Property | Type | Description |
|
|
139
|
-
|------------|------------------------|-------------------------------------------------|
|
|
140
|
-
| status | "success" or "error" | Status hasil operasi |
|
|
141
|
-
| message | string | Detail pesan atau informasi error |
|
|
142
|
-
| url | string or undefined | URL publik file (hanya tersedia jika success) |
|
|
143
|
-
| fileName | string or undefined | Nama file yang tersimpan di CDN |
|
|
119
|
+
## Error Handling
|
|
144
120
|
|
|
145
|
-
|
|
121
|
+
Library ini sudah menangani error secara internal. Jika upload gagal, fungsi akan mengembalikan object dengan `status: 'error'` dan `message` yang berisi keterangan kegagalan sehingga aplikasi Anda tidak akan crash.
|
|
146
122
|
|
|
147
|
-
|
|
123
|
+
```js
|
|
124
|
+
const { CloudKu } = require('@xstbot/cloudku');
|
|
148
125
|
|
|
149
|
-
|
|
126
|
+
async function safeUpload(buffer, filename) {
|
|
127
|
+
const result = await CloudKu(buffer, filename);
|
|
150
128
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
} else {
|
|
157
|
-
throw new Error(result.message);
|
|
158
|
-
}
|
|
159
|
-
} catch (error) {
|
|
160
|
-
console.error('Upload gagal:', (error as Error).message);
|
|
129
|
+
if (result.status === 'success') {
|
|
130
|
+
console.log('URL File:', result.url);
|
|
131
|
+
return result.url;
|
|
132
|
+
} else {
|
|
133
|
+
console.error('Upload gagal:', result.message);
|
|
161
134
|
return null;
|
|
162
135
|
}
|
|
163
136
|
}
|
|
137
|
+
```
|
|
164
138
|
|
|
165
139
|
---
|
|
166
140
|
|
|
167
|
-
##
|
|
141
|
+
## — Tautan Penting
|
|
168
142
|
|
|
169
143
|
| Sumber | URL |
|
|
170
144
|
|---------------|-----------------------------------------------|
|
|
171
145
|
| NPM Package | https://www.npmjs.com/package/@xstbot/cloudku |
|
|
172
|
-
| Dokumentasi | https://cloudku.sbs/docs
|
|
146
|
+
| Dokumentasi | https://cloudku.sbs/docs |
|
|
173
147
|
| CloudKu Utama | https://cloudku.sbs |
|
|
174
148
|
|
|
175
149
|
---
|
|
176
150
|
|
|
177
|
-
##
|
|
151
|
+
## Lisensi
|
|
178
152
|
|
|
179
|
-
Proyek ini dilisensikan di bawah
|
|
153
|
+
Proyek ini dilisensikan di bawah **MIT License**.
|
|
180
154
|
Kunjungi: https://www.npmjs.com/package/@xstbot/cloudku
|
|
181
155
|
|
|
182
156
|
---
|
|
183
157
|
|
|
184
|
-
>
|
|
158
|
+
> © 2026 CloudKu CDN API Developed for Modern Apps
|
package/dist/esm/index.js
CHANGED
|
@@ -1,78 +1,38 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import FormData from 'form-data';
|
|
3
|
-
|
|
4
|
-
// ─── Core Upload Function ─────────────────────────────────────────────────────
|
|
3
|
+
|
|
5
4
|
/**
|
|
6
|
-
* Upload
|
|
7
|
-
*
|
|
8
|
-
* @param
|
|
9
|
-
* @
|
|
10
|
-
* @param options - Optional configuration (apiUrl, timeout)
|
|
11
|
-
* @returns CDN response object
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { uploadFile } from 'cloudku-uploader';
|
|
16
|
-
* import fs from 'fs';
|
|
17
|
-
*
|
|
18
|
-
* const buffer = fs.readFileSync('./photo.jpg');
|
|
19
|
-
* const result = await uploadFile(buffer, 'photo.jpg');
|
|
20
|
-
* console.log(result);
|
|
21
|
-
* ```
|
|
5
|
+
* Upload file ke CloudKu CDN
|
|
6
|
+
* @param {Buffer} fileBuffer - Buffer dari file yang akan di-upload
|
|
7
|
+
* @param {string} fileName - Nama file beserta ekstensinya (contoh: "foto.jpg")
|
|
8
|
+
* @returns {Promise<Object>} Response dari CDN
|
|
22
9
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
throw new TypeError('fileBuffer must be a valid Buffer');
|
|
27
|
-
}
|
|
28
|
-
if (!fileName || typeof fileName !== 'string' || fileName.trim() === '') {
|
|
29
|
-
throw new TypeError('fileName must be a non-empty string');
|
|
30
|
-
}
|
|
31
|
-
const apiUrl = (_a = options.apiUrl) !== null && _a !== void 0 ? _a : CloudKu_URL;
|
|
32
|
-
const timeout = (_b = options.timeout) !== null && _b !== void 0 ? _b : 30000;
|
|
10
|
+
const CloudKu = async (fileBuffer, fileName) => {
|
|
11
|
+
try {
|
|
12
|
+
const url = 'https://cloudku.sbs/cdn/api.php';
|
|
33
13
|
const form = new FormData();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
timeout,
|
|
38
|
-
maxContentLength: Infinity,
|
|
39
|
-
maxBodyLength: Infinity,
|
|
14
|
+
|
|
15
|
+
form.append('file', fileBuffer, {
|
|
16
|
+
filename: fileName,
|
|
40
17
|
});
|
|
18
|
+
|
|
19
|
+
const response = await axios.post(url, form, {
|
|
20
|
+
headers: {
|
|
21
|
+
...form.getHeaders(),
|
|
22
|
+
},
|
|
23
|
+
maxContentLength: Infinity,
|
|
24
|
+
maxBodyLength: Infinity,
|
|
25
|
+
});
|
|
26
|
+
|
|
41
27
|
return response.data;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('CloudKu Upload Error:', error.response?.data || error.message);
|
|
30
|
+
return {
|
|
31
|
+
status: 'error',
|
|
32
|
+
message: error.response?.data?.message || error.message,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
42
35
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* import { CloudKu } from 'cloudku-uploader';
|
|
50
|
-
*
|
|
51
|
-
* const client = new CloudKu({ timeout: 60_000 });
|
|
52
|
-
* const result = await client.upload(buffer, 'video.mp4');
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export class CloudKu {
|
|
56
|
-
constructor(options = {}) {
|
|
57
|
-
var _a, _b;
|
|
58
|
-
this.options = {
|
|
59
|
-
apiUrl: (_a = options.apiUrl) !== null && _a !== void 0 ? _a : CloudKu_URL,
|
|
60
|
-
timeout: (_b = options.timeout) !== null && _b !== void 0 ? _b : 30000,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Upload a file to CloudKu CDN.
|
|
65
|
-
* @param fileBuffer - File content as a Buffer
|
|
66
|
-
* @param fileName - File name with extension
|
|
67
|
-
*/
|
|
68
|
-
async upload(fileBuffer, fileName) {
|
|
69
|
-
return uploadFile(fileBuffer, fileName, this.options);
|
|
70
|
-
}
|
|
71
|
-
/** Returns the active configuration of this client instance */
|
|
72
|
-
getOptions() {
|
|
73
|
-
return { ...this.options };
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// ─── Default Export ───────────────────────────────────────────────────────────
|
|
77
|
-
export default CloudKu;
|
|
78
|
-
//# sourceMappingURL=index.js.map
|
|
36
|
+
|
|
37
|
+
export { CloudKu };
|
|
38
|
+
export default CloudKu;
|
package/dist/index.js
CHANGED
|
@@ -1,86 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.CloudKu = exports.uploadFile = exports.CloudKu_URL = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
9
|
-
exports.CloudKu_URL = 'https://cloudku.sbs/cdn/api.php';
|
|
10
|
-
// ─── Core Upload Function ─────────────────────────────────────────────────────
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const axios = require('axios');
|
|
4
|
+
const FormData = require('form-data');
|
|
5
|
+
|
|
11
6
|
/**
|
|
12
|
-
* Upload
|
|
13
|
-
*
|
|
14
|
-
* @param
|
|
15
|
-
* @
|
|
16
|
-
* @param options - Optional configuration (apiUrl, timeout)
|
|
17
|
-
* @returns CDN response object
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* import { uploadFile } from 'cloudku-uploader';
|
|
22
|
-
* import fs from 'fs';
|
|
23
|
-
*
|
|
24
|
-
* const buffer = fs.readFileSync('./photo.jpg');
|
|
25
|
-
* const result = await uploadFile(buffer, 'photo.jpg');
|
|
26
|
-
* console.log(result);
|
|
27
|
-
* ```
|
|
7
|
+
* Upload file ke CloudKu CDN
|
|
8
|
+
* @param {Buffer} fileBuffer - Buffer dari file yang akan di-upload
|
|
9
|
+
* @param {string} fileName - Nama file beserta ekstensinya (contoh: "foto.jpg")
|
|
10
|
+
* @returns {Promise<Object>} Response dari CDN
|
|
28
11
|
*/
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
maxContentLength: Infinity,
|
|
45
|
-
maxBodyLength: Infinity,
|
|
12
|
+
const CloudKu = async (fileBuffer, fileName) => {
|
|
13
|
+
try {
|
|
14
|
+
const url = 'https://cloudku.sbs/cdn/api.php';
|
|
15
|
+
const form = new FormData();
|
|
16
|
+
|
|
17
|
+
form.append('file', fileBuffer, {
|
|
18
|
+
filename: fileName,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const response = await axios.post(url, form, {
|
|
22
|
+
headers: {
|
|
23
|
+
...form.getHeaders(),
|
|
24
|
+
},
|
|
25
|
+
maxContentLength: Infinity,
|
|
26
|
+
maxBodyLength: Infinity,
|
|
46
27
|
});
|
|
28
|
+
|
|
47
29
|
return response.data;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error('CloudKu Upload Error:', error.response?.data || error.message);
|
|
32
|
+
return {
|
|
33
|
+
status: 'error',
|
|
34
|
+
message: error.response?.data?.message || error.message,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
48
37
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* CloudKu class — instance-based client with persistent configuration.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* import { CloudKu } from 'cloudku-uploader';
|
|
57
|
-
*
|
|
58
|
-
* const client = new CloudKu({ timeout: 60_000 });
|
|
59
|
-
* const result = await client.upload(buffer, 'video.mp4');
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
class CloudKu {
|
|
63
|
-
constructor(options = {}) {
|
|
64
|
-
var _a, _b;
|
|
65
|
-
this.options = {
|
|
66
|
-
apiUrl: (_a = options.apiUrl) !== null && _a !== void 0 ? _a : exports.CloudKu_URL,
|
|
67
|
-
timeout: (_b = options.timeout) !== null && _b !== void 0 ? _b : 30000,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Upload a file to CloudKu CDN.
|
|
72
|
-
* @param fileBuffer - File content as a Buffer
|
|
73
|
-
* @param fileName - File name with extension
|
|
74
|
-
*/
|
|
75
|
-
async upload(fileBuffer, fileName) {
|
|
76
|
-
return (0, exports.uploadFile)(fileBuffer, fileName, this.options);
|
|
77
|
-
}
|
|
78
|
-
/** Returns the active configuration of this client instance */
|
|
79
|
-
getOptions() {
|
|
80
|
-
return { ...this.options };
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.CloudKu = CloudKu;
|
|
84
|
-
// ─── Default Export ───────────────────────────────────────────────────────────
|
|
85
|
-
exports.default = CloudKu;
|
|
86
|
-
//# sourceMappingURL=index.js.map
|
|
38
|
+
|
|
39
|
+
module.exports = { CloudKu };
|
package/package.json
CHANGED
|
@@ -1,70 +1,59 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"require": "./dist/index.js",
|
|
14
|
-
"types": "./dist/index.d.ts"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build:cjs": "tsc --project tsconfig.json",
|
|
22
|
-
"build:esm": "tsc --project tsconfig.esm.json",
|
|
23
|
-
"build": "npm run build:cjs && npm run build:esm",
|
|
24
|
-
"prepare": "npm run build",
|
|
25
|
-
"clean": "rimraf dist"
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"cloudku",
|
|
29
|
-
"cloudku-cdn",
|
|
30
|
-
"cdn",
|
|
31
|
-
"free-cdn",
|
|
32
|
-
"cloud-storage",
|
|
33
|
-
"file-upload",
|
|
34
|
-
"upload-file",
|
|
35
|
-
"uploader",
|
|
36
|
-
"cloud-uploader",
|
|
37
|
-
"storage",
|
|
38
|
-
"object-storage",
|
|
39
|
-
"media-upload",
|
|
40
|
-
"image-upload",
|
|
41
|
-
"video-upload",
|
|
42
|
-
"nodejs",
|
|
43
|
-
"typescript",
|
|
44
|
-
"javascript",
|
|
45
|
-
"api-client",
|
|
46
|
-
"rest-api",
|
|
47
|
-
"cdn-uploader",
|
|
48
|
-
"file-hosting",
|
|
49
|
-
"hosting",
|
|
50
|
-
"cloud-service",
|
|
51
|
-
"free-cloud"
|
|
52
|
-
],
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"axios": "^1.6.0",
|
|
55
|
-
"form-data": "^4.0.0"
|
|
56
|
-
},
|
|
57
|
-
"devDependencies": {
|
|
58
|
-
"@types/node": "^20.0.0",
|
|
59
|
-
"@types/form-data": "^2.5.0",
|
|
60
|
-
"typescript": "^5.3.0",
|
|
61
|
-
"rimraf": "^5.0.0"
|
|
62
|
-
},
|
|
63
|
-
"engines": {
|
|
64
|
-
"node": ">=14.0.0"
|
|
65
|
-
},
|
|
66
|
-
"repository": {
|
|
67
|
-
"type": "git",
|
|
68
|
-
"url": "https://github.com/xstbot-cloudku/cloudku.git"
|
|
2
|
+
"name": "@xstbot/cloudku",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "CloudKu CDN Uploader Library",
|
|
5
|
+
"author": "xstbot",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/esm/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"require": "./dist/index.js"
|
|
69
13
|
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "node scripts/build.js",
|
|
20
|
+
"prepare": "npm run build",
|
|
21
|
+
"clean": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});console.log('🗑️ dist dihapus');\""
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"cloudku",
|
|
25
|
+
"cloudku-cdn",
|
|
26
|
+
"cdn",
|
|
27
|
+
"free-cdn",
|
|
28
|
+
"cloud-storage",
|
|
29
|
+
"file-upload",
|
|
30
|
+
"upload-file",
|
|
31
|
+
"uploader",
|
|
32
|
+
"cloud-uploader",
|
|
33
|
+
"storage",
|
|
34
|
+
"object-storage",
|
|
35
|
+
"media-upload",
|
|
36
|
+
"image-upload",
|
|
37
|
+
"video-upload",
|
|
38
|
+
"nodejs",
|
|
39
|
+
"javascript",
|
|
40
|
+
"api-client",
|
|
41
|
+
"rest-api",
|
|
42
|
+
"cdn-uploader",
|
|
43
|
+
"file-hosting",
|
|
44
|
+
"hosting",
|
|
45
|
+
"cloud-service",
|
|
46
|
+
"free-cloud"
|
|
47
|
+
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"axios": "^1.6.0",
|
|
50
|
+
"form-data": "^4.0.0"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=14.0.0"
|
|
54
|
+
},
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "https://github.com/xstbot-cloudku/cloudku.git"
|
|
58
|
+
}
|
|
70
59
|
}
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA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I,CAAC,OAAO,GAAG;YACX,MAAM,EAAE,MAAA,OAAO,CAAC,MAAM,mCAAI,WAAW;YACrC,OAAO,EAAE,MAAA,OAAO,CAAC,OAAO,mCAAI,KAAM;SACrC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,UAAkB,EAAE,QAAgB;QAC7C,OAAO,UAAU,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,+DAA+D;IAC/D,UAAU;QACN,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;CACJ;AAED,iFAAiF;AAEjF,eAAe,OAAO,CAAC"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export declare const CloudKu_URL = "https://cloudku.sbs/cdn/api.php";
|
|
2
|
-
export interface CloudKuOptions {
|
|
3
|
-
/** Custom API endpoint. Default: CloudKu CDN */
|
|
4
|
-
apiUrl?: string;
|
|
5
|
-
/** Request timeout in milliseconds. Default: 30000 */
|
|
6
|
-
timeout?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface CloudKuSuccessResponse {
|
|
9
|
-
status: 'success' | string;
|
|
10
|
-
url?: string;
|
|
11
|
-
fileName?: string;
|
|
12
|
-
[key: string]: unknown;
|
|
13
|
-
}
|
|
14
|
-
export interface CloudKuErrorResponse {
|
|
15
|
-
status: 'error';
|
|
16
|
-
message: string;
|
|
17
|
-
}
|
|
18
|
-
export type CloudKuResponse = CloudKuSuccessResponse | CloudKuErrorResponse;
|
|
19
|
-
/**
|
|
20
|
-
* Upload a file Buffer to CloudKu CDN.
|
|
21
|
-
*
|
|
22
|
-
* @param fileBuffer - File content as a Node.js Buffer
|
|
23
|
-
* @param fileName - File name including extension (e.g. `photo.jpg`)
|
|
24
|
-
* @param options - Optional configuration (apiUrl, timeout)
|
|
25
|
-
* @returns CDN response object
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* import { uploadFile } from 'cloudku-uploader';
|
|
30
|
-
* import fs from 'fs';
|
|
31
|
-
*
|
|
32
|
-
* const buffer = fs.readFileSync('./photo.jpg');
|
|
33
|
-
* const result = await uploadFile(buffer, 'photo.jpg');
|
|
34
|
-
* console.log(result);
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare const uploadFile: (fileBuffer: Buffer, fileName: string, options?: CloudKuOptions) => Promise<CloudKuResponse>;
|
|
38
|
-
/**
|
|
39
|
-
* CloudKu class — instance-based client with persistent configuration.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* import { CloudKu } from 'cloudku-uploader';
|
|
44
|
-
*
|
|
45
|
-
* const client = new CloudKu({ timeout: 60_000 });
|
|
46
|
-
* const result = await client.upload(buffer, 'video.mp4');
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export declare class CloudKu {
|
|
50
|
-
private readonly options;
|
|
51
|
-
constructor(options?: CloudKuOptions);
|
|
52
|
-
/**
|
|
53
|
-
* Upload a file to CloudKu CDN.
|
|
54
|
-
* @param fileBuffer - File content as a Buffer
|
|
55
|
-
* @param fileName - File name with extension
|
|
56
|
-
*/
|
|
57
|
-
upload(fileBuffer: Buffer, fileName: string): Promise<CloudKuResponse>;
|
|
58
|
-
/** Returns the active configuration of this client instance */
|
|
59
|
-
getOptions(): Readonly<Required<CloudKuOptions>>;
|
|
60
|
-
}
|
|
61
|
-
export default CloudKu;
|
|
62
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,oCAAoC,CAAC;AAI7D,MAAM,WAAW,cAAc;IAC3B,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM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