cloudxs 0.1.3 → 1.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/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -3
- package/dist/index.mjs +7 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
27
27
|
// src/client.ts
|
|
28
28
|
var CloudXS = class {
|
|
29
29
|
constructor(config) {
|
|
30
|
+
this.CDN_BASE_URL = "https://cdn.cloudxs.app";
|
|
30
31
|
if (!config.apiKey) {
|
|
31
32
|
throw new Error("CloudXS API key is required");
|
|
32
33
|
}
|
|
@@ -44,10 +45,12 @@ var CloudXS = class {
|
|
|
44
45
|
apiKey: this.apiKey
|
|
45
46
|
})
|
|
46
47
|
});
|
|
48
|
+
const json = await res.json();
|
|
49
|
+
console.log(json);
|
|
47
50
|
if (!res.ok) {
|
|
48
|
-
throw new Error("Failed to get upload URL"
|
|
51
|
+
throw new Error(json.message || "Failed to get upload URL");
|
|
49
52
|
}
|
|
50
|
-
const { uploadUrl } =
|
|
53
|
+
const { uploadUrl, key } = json;
|
|
51
54
|
const uploadRes = await fetch(uploadUrl, {
|
|
52
55
|
method: "PUT",
|
|
53
56
|
headers: {
|
|
@@ -55,12 +58,13 @@ var CloudXS = class {
|
|
|
55
58
|
},
|
|
56
59
|
body: file
|
|
57
60
|
});
|
|
61
|
+
console.log(uploadRes);
|
|
58
62
|
if (!uploadRes.ok) {
|
|
59
63
|
throw new Error("Upload failed");
|
|
60
64
|
}
|
|
61
65
|
return {
|
|
62
66
|
success: true,
|
|
63
|
-
|
|
67
|
+
url: `${this.CDN_BASE_URL}/${key}`
|
|
64
68
|
};
|
|
65
69
|
}
|
|
66
70
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/client.ts
|
|
2
2
|
var CloudXS = class {
|
|
3
3
|
constructor(config) {
|
|
4
|
+
this.CDN_BASE_URL = "https://cdn.cloudxs.app";
|
|
4
5
|
if (!config.apiKey) {
|
|
5
6
|
throw new Error("CloudXS API key is required");
|
|
6
7
|
}
|
|
@@ -18,10 +19,12 @@ var CloudXS = class {
|
|
|
18
19
|
apiKey: this.apiKey
|
|
19
20
|
})
|
|
20
21
|
});
|
|
22
|
+
const json = await res.json();
|
|
23
|
+
console.log(json);
|
|
21
24
|
if (!res.ok) {
|
|
22
|
-
throw new Error("Failed to get upload URL"
|
|
25
|
+
throw new Error(json.message || "Failed to get upload URL");
|
|
23
26
|
}
|
|
24
|
-
const { uploadUrl } =
|
|
27
|
+
const { uploadUrl, key } = json;
|
|
25
28
|
const uploadRes = await fetch(uploadUrl, {
|
|
26
29
|
method: "PUT",
|
|
27
30
|
headers: {
|
|
@@ -29,12 +32,13 @@ var CloudXS = class {
|
|
|
29
32
|
},
|
|
30
33
|
body: file
|
|
31
34
|
});
|
|
35
|
+
console.log(uploadRes);
|
|
32
36
|
if (!uploadRes.ok) {
|
|
33
37
|
throw new Error("Upload failed");
|
|
34
38
|
}
|
|
35
39
|
return {
|
|
36
40
|
success: true,
|
|
37
|
-
|
|
41
|
+
url: `${this.CDN_BASE_URL}/${key}`
|
|
38
42
|
};
|
|
39
43
|
}
|
|
40
44
|
};
|