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 CHANGED
@@ -1,11 +1,12 @@
1
1
  declare class CloudXS {
2
2
  private apiKey;
3
+ private CDN_BASE_URL;
3
4
  constructor(config: {
4
5
  apiKey: string;
5
6
  });
6
7
  upload(file: File): Promise<{
7
8
  success: boolean;
8
- filename: string;
9
+ url: string;
9
10
  }>;
10
11
  }
11
12
 
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  declare class CloudXS {
2
2
  private apiKey;
3
+ private CDN_BASE_URL;
3
4
  constructor(config: {
4
5
  apiKey: string;
5
6
  });
6
7
  upload(file: File): Promise<{
7
8
  success: boolean;
8
- filename: string;
9
+ url: string;
9
10
  }>;
10
11
  }
11
12
 
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" + res);
51
+ throw new Error(json.message || "Failed to get upload URL");
49
52
  }
50
- const { uploadUrl } = await res.json();
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
- filename: file.name
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" + res);
25
+ throw new Error(json.message || "Failed to get upload URL");
23
26
  }
24
- const { uploadUrl } = await res.json();
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
- filename: file.name
41
+ url: `${this.CDN_BASE_URL}/${key}`
38
42
  };
39
43
  }
40
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudxs",
3
- "version": "0.1.3",
3
+ "version": "1.0.0",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",