cloudxs 0.1.1 → 0.1.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/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +14 -5
- package/dist/index.mjs +14 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -26,8 +26,14 @@ module.exports = __toCommonJS(index_exports);
|
|
|
26
26
|
|
|
27
27
|
// src/client.ts
|
|
28
28
|
var CloudXS = class {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
constructor(config) {
|
|
30
|
+
if (!config.apiKey) {
|
|
31
|
+
throw new Error("CloudXS API key is required");
|
|
32
|
+
}
|
|
33
|
+
this.apiKey = config.apiKey;
|
|
34
|
+
}
|
|
35
|
+
async upload(file) {
|
|
36
|
+
const res = await fetch("http://localhost:5000/upload/upload-url", {
|
|
31
37
|
method: "POST",
|
|
32
38
|
headers: {
|
|
33
39
|
"Content-Type": "application/json"
|
|
@@ -35,11 +41,11 @@ var CloudXS = class {
|
|
|
35
41
|
body: JSON.stringify({
|
|
36
42
|
filename: file.name,
|
|
37
43
|
filetype: file.type,
|
|
38
|
-
apiKey
|
|
44
|
+
apiKey: this.apiKey
|
|
39
45
|
})
|
|
40
46
|
});
|
|
41
47
|
if (!res.ok) {
|
|
42
|
-
throw new Error("Failed to get upload URL");
|
|
48
|
+
throw new Error("Failed to get upload URL" + res);
|
|
43
49
|
}
|
|
44
50
|
const { uploadUrl } = await res.json();
|
|
45
51
|
const uploadRes = await fetch(uploadUrl, {
|
|
@@ -52,7 +58,10 @@ var CloudXS = class {
|
|
|
52
58
|
if (!uploadRes.ok) {
|
|
53
59
|
throw new Error("Upload failed");
|
|
54
60
|
}
|
|
55
|
-
|
|
61
|
+
return {
|
|
62
|
+
success: true,
|
|
63
|
+
filename: file.name
|
|
64
|
+
};
|
|
56
65
|
}
|
|
57
66
|
};
|
|
58
67
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// src/client.ts
|
|
2
2
|
var CloudXS = class {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
constructor(config) {
|
|
4
|
+
if (!config.apiKey) {
|
|
5
|
+
throw new Error("CloudXS API key is required");
|
|
6
|
+
}
|
|
7
|
+
this.apiKey = config.apiKey;
|
|
8
|
+
}
|
|
9
|
+
async upload(file) {
|
|
10
|
+
const res = await fetch("http://localhost:5000/upload/upload-url", {
|
|
5
11
|
method: "POST",
|
|
6
12
|
headers: {
|
|
7
13
|
"Content-Type": "application/json"
|
|
@@ -9,11 +15,11 @@ var CloudXS = class {
|
|
|
9
15
|
body: JSON.stringify({
|
|
10
16
|
filename: file.name,
|
|
11
17
|
filetype: file.type,
|
|
12
|
-
apiKey
|
|
18
|
+
apiKey: this.apiKey
|
|
13
19
|
})
|
|
14
20
|
});
|
|
15
21
|
if (!res.ok) {
|
|
16
|
-
throw new Error("Failed to get upload URL");
|
|
22
|
+
throw new Error("Failed to get upload URL" + res);
|
|
17
23
|
}
|
|
18
24
|
const { uploadUrl } = await res.json();
|
|
19
25
|
const uploadRes = await fetch(uploadUrl, {
|
|
@@ -26,7 +32,10 @@ var CloudXS = class {
|
|
|
26
32
|
if (!uploadRes.ok) {
|
|
27
33
|
throw new Error("Upload failed");
|
|
28
34
|
}
|
|
29
|
-
|
|
35
|
+
return {
|
|
36
|
+
success: true,
|
|
37
|
+
filename: file.name
|
|
38
|
+
};
|
|
30
39
|
}
|
|
31
40
|
};
|
|
32
41
|
export {
|