cloudxs 0.1.4 → 1.0.1

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,13 +27,14 @@ 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
  }
33
34
  this.apiKey = config.apiKey;
34
35
  }
35
36
  async upload(file) {
36
- const res = await fetch("http://localhost:5000/upload/upload-url", {
37
+ const res = await fetch("https://api.cloudxs.app/upload/upload-url", {
37
38
  method: "POST",
38
39
  headers: {
39
40
  "Content-Type": "application/json"
@@ -45,10 +46,11 @@ var CloudXS = class {
45
46
  })
46
47
  });
47
48
  const json = await res.json();
49
+ console.log(json);
48
50
  if (!res.ok) {
49
- throw new Error("Failed to get upload URL" + json + file + file.name + file.type);
51
+ throw new Error(json.message || "Failed to get upload URL");
50
52
  }
51
- const { uploadUrl } = await res.json();
53
+ const { uploadUrl, key } = json;
52
54
  const uploadRes = await fetch(uploadUrl, {
53
55
  method: "PUT",
54
56
  headers: {
@@ -56,12 +58,13 @@ var CloudXS = class {
56
58
  },
57
59
  body: file
58
60
  });
61
+ console.log(uploadRes);
59
62
  if (!uploadRes.ok) {
60
63
  throw new Error("Upload failed");
61
64
  }
62
65
  return {
63
66
  success: true,
64
- filename: file.name
67
+ url: `${this.CDN_BASE_URL}/${key}`
65
68
  };
66
69
  }
67
70
  };
package/dist/index.mjs CHANGED
@@ -1,13 +1,14 @@
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
  }
7
8
  this.apiKey = config.apiKey;
8
9
  }
9
10
  async upload(file) {
10
- const res = await fetch("http://localhost:5000/upload/upload-url", {
11
+ const res = await fetch("https://api.cloudxs.app/upload/upload-url", {
11
12
  method: "POST",
12
13
  headers: {
13
14
  "Content-Type": "application/json"
@@ -19,10 +20,11 @@ var CloudXS = class {
19
20
  })
20
21
  });
21
22
  const json = await res.json();
23
+ console.log(json);
22
24
  if (!res.ok) {
23
- throw new Error("Failed to get upload URL" + json + file + file.name + file.type);
25
+ throw new Error(json.message || "Failed to get upload URL");
24
26
  }
25
- const { uploadUrl } = await res.json();
27
+ const { uploadUrl, key } = json;
26
28
  const uploadRes = await fetch(uploadUrl, {
27
29
  method: "PUT",
28
30
  headers: {
@@ -30,12 +32,13 @@ var CloudXS = class {
30
32
  },
31
33
  body: file
32
34
  });
35
+ console.log(uploadRes);
33
36
  if (!uploadRes.ok) {
34
37
  throw new Error("Upload failed");
35
38
  }
36
39
  return {
37
40
  success: true,
38
- filename: file.name
41
+ url: `${this.CDN_BASE_URL}/${key}`
39
42
  };
40
43
  }
41
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudxs",
3
- "version": "0.1.4",
3
+ "version": "1.0.1",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",