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 CHANGED
@@ -1,5 +1,12 @@
1
1
  declare class CloudXS {
2
- upload(file: File, apiKey: string): Promise<void>;
2
+ private apiKey;
3
+ constructor(config: {
4
+ apiKey: string;
5
+ });
6
+ upload(file: File): Promise<{
7
+ success: boolean;
8
+ filename: string;
9
+ }>;
3
10
  }
4
11
 
5
12
  export { CloudXS };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  declare class CloudXS {
2
- upload(file: File, apiKey: string): Promise<void>;
2
+ private apiKey;
3
+ constructor(config: {
4
+ apiKey: string;
5
+ });
6
+ upload(file: File): Promise<{
7
+ success: boolean;
8
+ filename: string;
9
+ }>;
3
10
  }
4
11
 
5
12
  export { CloudXS };
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
- async upload(file, apiKey) {
30
- const res = await fetch("https://localhost:5000/upload/upload-url", {
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
- console.log("Upload successful \u{1F389}");
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
- async upload(file, apiKey) {
4
- const res = await fetch("https://localhost:5000/upload/upload-url", {
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
- console.log("Upload successful \u{1F389}");
35
+ return {
36
+ success: true,
37
+ filename: file.name
38
+ };
30
39
  }
31
40
  };
32
41
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudxs",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",