lesca-node-bunnycdn 0.0.21 → 0.0.23

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/lib/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function P(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var O={exports:{}},r=O.exports={},c,u;function b(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?c=setTimeout:c=b}catch{c=b}try{typeof clearTimeout=="function"?u=clearTimeout:u=E}catch{u=E}})();function S(e){if(c===setTimeout)return setTimeout(e,0);if((c===b||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch{try{return c.call(null,e,0)}catch{return c.call(this,e,0)}}}function R(e){if(u===clearTimeout)return clearTimeout(e);if((u===E||!u)&&clearTimeout)return u=clearTimeout,clearTimeout(e);try{return u(e)}catch{try{return u.call(null,e)}catch{return u.call(this,e)}}}var l=[],N=!1,g,y=-1;function D(){!N||!g||(N=!1,g.length?l=g.concat(l):y=-1,l.length&&U())}function U(){if(!N){var e=S(D);N=!0;for(var t=l.length;t;){for(g=l,l=[];++y<t;)g&&g[y].run();y=-1,t=l.length}g=null,N=!1,R(e)}}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)t[s-1]=arguments[s];l.push(new A(e,t)),l.length===1&&!N&&S(U)};function A(e,t){this.fun=e,this.array=t}A.prototype.run=function(){this.fun.apply(null,this.array)};r.title="browser";r.browser=!0;r.env={};r.argv=[];r.version="";r.versions={};function f(){}r.on=f;r.addListener=f;r.once=f;r.off=f;r.removeListener=f;r.removeAllListeners=f;r.emit=f;r.prependListener=f;r.prependOnceListener=f;r.listeners=function(e){return[]};r.binding=function(e){throw new Error("process.binding is not supported")};r.cwd=function(){return"/"};r.chdir=function(e){throw new Error("process.chdir is not supported")};r.umask=function(){return 0};var Y=O.exports;const h=P(Y),_=(e={})=>({region:e.region||h.env.BUNNY_REGION||"SG",baseHostName:"storage.bunnycdn.com",folderName:e.folderName||h.env.BUNNY_FOLDER_NAME||"",storageZone:e.storageZone||h.env.BUNNY_STORAGE_ZONE||"unset",password:e.password||h.env.BUNNY_PASSWORD||"unset"}),F=({storageZone:e,password:t,region:s,folderName:i})=>{e&&(h.env.BUNNY_STORAGE_ZONE=e),t&&(h.env.BUNNY_PASSWORD=t),s&&(h.env.BUNNY_REGION=s),i&&(h.env.BUNNY_FOLDER_NAME=i)},L=async({file:e,buffer:t,folder:s,...i})=>new Promise(async(n,a)=>{try{!t&&!e&&a({res:!1,message:"No file uploaded"});const o=_(i),p=t?t.length:e.buffer.length,m=o.folderName?`${o.folderName}/`:"",w=s?`${s}/`:"",d=`${new Date().getTime()}.webp`,$={method:"PUT",hostname:o.region?`${o.region}.${o.baseHostName}`:o.baseHostName,port:443,path:`/${o.storageZone}/${m}${w}${d}`,headers:{AccessKey:o.password,"Content-Type":"application/octet-stream","Content-Length":p.toString()}},T=await fetch(`https://${$.hostname}${$.path}`,{method:"PUT",headers:$.headers,body:t||e.buffer});if(T.status===201){const v=`https://${o.storageZone}.b-cdn.net/${m}${w}${d}`;n({res:!0,message:"upload success",url:v})}else a({res:!1,message:"Upload failed",error:await T.text()})}catch{a({res:!1,message:"Server error"})}}),B=async({folder:e="",configOverrides:t={}}={})=>new Promise((s,i)=>{try{const n=_(t),a=n.region?`${n.region}.${n.baseHostName}`:n.baseHostName,o=n.folderName?`${n.folderName}/`:"",p=e?`${e}/`:"",m=`https://${a}/${n.storageZone}/${o}${p}`,w={AccessKey:n.password};fetch(m,{headers:w}).then(d=>d.json()).then(d=>{const $=d.map(T=>{const v=`https://${n.storageZone}.b-cdn.net/${o}${p}${T.ObjectName}`;return{...T,Url:v}});s({res:!0,message:"List retrieved successfully",files:$})}).catch(d=>{i({res:!1,message:"Network error",error:d})})}catch{i({res:!1,message:"Server error"})}}),C=({ObjectName:e,href:t,...s})=>new Promise((i,n)=>{if(!e&&!t){n({res:!1,message:"No file specified for deletion"});return}try{const a=_(s),o=a.region?`${a.region}.${a.baseHostName}`:a.baseHostName,p=t?decodeURIComponent(t.split("/")[t.split("/").length-1]):e;fetch(`https://${o}/${a.storageZone}/${a.folderName}/${p}`,{method:"DELETE",headers:{AccessKey:a.password}}).then(m=>{m.status===200?i({res:!0,message:"File deleted successfully"}):i({res:!1,message:"Failed to delete file"})}).catch(m=>{n({res:!1,message:"Network error",error:m})})}catch{n({res:!1,message:"Server error"})}}),Z={install:F,upload:L,list:B,deleteFile:C};exports.default=Z;exports.deleteFile=C;exports.install=F;exports.list=B;exports.upload=L;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function R(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var O={exports:{}},r=O.exports={},u,f;function b(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?u=setTimeout:u=b}catch{u=b}try{typeof clearTimeout=="function"?f=clearTimeout:f=E}catch{f=E}})();function S(e){if(u===setTimeout)return setTimeout(e,0);if((u===b||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch{try{return u.call(null,e,0)}catch{return u.call(this,e,0)}}}function D(e){if(f===clearTimeout)return clearTimeout(e);if((f===E||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch{try{return f.call(null,e)}catch{return f.call(this,e)}}}var d=[],$=!1,g,v=-1;function Y(){!$||!g||($=!1,g.length?d=g.concat(d):v=-1,d.length&&U())}function U(){if(!$){var e=S(Y);$=!0;for(var t=d.length;t;){for(g=d,d=[];++v<t;)g&&g[v].run();v=-1,t=d.length}g=null,$=!1,D(e)}}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];d.push(new A(e,t)),d.length===1&&!$&&S(U)};function A(e,t){this.fun=e,this.array=t}A.prototype.run=function(){this.fun.apply(null,this.array)};r.title="browser";r.browser=!0;r.env={};r.argv=[];r.version="";r.versions={};function m(){}r.on=m;r.addListener=m;r.once=m;r.off=m;r.removeListener=m;r.removeAllListeners=m;r.emit=m;r.prependListener=m;r.prependOnceListener=m;r.listeners=function(e){return[]};r.binding=function(e){throw new Error("process.binding is not supported")};r.cwd=function(){return"/"};r.chdir=function(e){throw new Error("process.chdir is not supported")};r.umask=function(){return 0};var Z=O.exports;const h=R(Z),_=(e={})=>({region:e.region||h.env.BUNNY_REGION||"SG",baseHostName:"storage.bunnycdn.com",folderName:e.folderName||h.env.BUNNY_FOLDER_NAME||"",storageZone:e.storageZone||h.env.BUNNY_STORAGE_ZONE||"unset",password:e.password||h.env.BUNNY_PASSWORD||"unset"}),P=({storageZone:e,password:t,region:n,folderName:c})=>{e&&(h.env.BUNNY_STORAGE_ZONE=e),t&&(h.env.BUNNY_PASSWORD=t),n&&(h.env.BUNNY_REGION=n),c&&(h.env.BUNNY_FOLDER_NAME=c)},L=async({file:e,buffer:t,folder:n,format:c,...o})=>new Promise(async(p,l)=>{try{!t&&!e&&l({res:!1,message:"No file uploaded"});const s=_(o),y=t?t.length:e.buffer.length,N=s.folderName?`${s.folderName}/`:"",a=n?`${n}/`:"",w=c||"jpg",i=`${new Date().getTime()}.${w}`,T={method:"PUT",hostname:s.region?`${s.region}.${s.baseHostName}`:s.baseHostName,port:443,path:`/${s.storageZone}/${N}${a}${i}`,headers:{AccessKey:s.password,"Content-Type":"application/octet-stream","Content-Length":y.toString()}},F=await fetch(`https://${T.hostname}${T.path}`,{method:"PUT",headers:T.headers,body:t||e.buffer});if(F.status===201){const H=`https://${s.storageZone}.b-cdn.net/${N}${a}${i}`;p({res:!0,message:"upload success",url:H})}else l({res:!1,message:"Upload failed",error:await F.text()})}catch{l({res:!1,message:"Server error"})}}),B=async({folder:e="",configOverrides:t={}}={})=>new Promise((n,c)=>{try{const o=_(t),p=o.region?`${o.region}.${o.baseHostName}`:o.baseHostName,l=o.folderName?`${o.folderName}/`:"",s=e?`${e}/`:"",y=`https://${p}/${o.storageZone}/${l}${s}`,N={AccessKey:o.password};fetch(y,{headers:N}).then(a=>a.json()).then(a=>{const w=a.map(i=>{const T=`https://${o.storageZone}.b-cdn.net/${l}${s}${i.ObjectName}`;return{...i,Url:T}});n({res:!0,message:"List retrieved successfully",files:w})}).catch(a=>{c({res:!1,message:"Network error",error:a})})}catch{c({res:!1,message:"Server error"})}}),C=({ObjectName:e,href:t,...n})=>new Promise((c,o)=>{if(!e&&!t){o({res:!1,message:"No file specified for deletion"});return}try{let p="",l="";if(t){const a=t.split("/").filter(i=>i!==""&&!i.includes("http"));if([...a].pop()?.includes(".")||!1){const i=[...a];p=decodeURIComponent(i.pop()||""),l=i.splice(1,1).join("/")}else l=[...a].splice(1,1).join("/")}const s=_(n),y=s.region?`${s.region}.${s.baseHostName}`:s.baseHostName,N=l?`/${l}`:"";fetch(`https://${y}/${s.storageZone}${N}/${p}`,{method:"DELETE",headers:{AccessKey:s.password}}).then(a=>{a.status===200?c({res:!0,message:"File deleted successfully"}):c({res:!1,message:"Failed to delete file"})}).catch(a=>{o({res:!1,message:"Network error",error:a})})}catch{o({res:!1,message:"Server error"})}}),x={install:P,upload:L,list:B,deleteFile:C};exports.default=x;exports.deleteFile=C;exports.install=P;exports.list=B;exports.upload=L;
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { File, InstallParams, ListParams, UploadParams } from './type';
2
2
  export declare const install: ({ storageZone, password, region, folderName }: InstallParams) => void;
3
- export declare const upload: ({ file, buffer, folder, ...configOverrides }: UploadParams & Partial<InstallParams>) => Promise<{
3
+ export declare const upload: ({ file, buffer, folder, format, ...configOverrides }: UploadParams & Partial<InstallParams>) => Promise<{
4
4
  res: boolean;
5
5
  message: string;
6
6
  url?: string;
@@ -20,7 +20,7 @@ export declare const deleteFile: ({ ObjectName, href, ...configOverrides }: {
20
20
  }>;
21
21
  declare const BunnyCDN: {
22
22
  install: ({ storageZone, password, region, folderName }: InstallParams) => void;
23
- upload: ({ file, buffer, folder, ...configOverrides }: UploadParams & Partial<InstallParams>) => Promise<{
23
+ upload: ({ file, buffer, folder, format, ...configOverrides }: UploadParams & Partial<InstallParams>) => Promise<{
24
24
  res: boolean;
25
25
  message: string;
26
26
  url?: string;
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
- function L(e) {
1
+ function P(e) {
2
2
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
3
3
  }
4
- var O = { exports: {} }, r = O.exports = {}, i, u;
4
+ var F = { exports: {} }, r = F.exports = {}, u, f;
5
5
  function b() {
6
6
  throw new Error("setTimeout has not been defined");
7
7
  }
@@ -10,60 +10,60 @@ function E() {
10
10
  }
11
11
  (function() {
12
12
  try {
13
- typeof setTimeout == "function" ? i = setTimeout : i = b;
13
+ typeof setTimeout == "function" ? u = setTimeout : u = b;
14
14
  } catch {
15
- i = b;
15
+ u = b;
16
16
  }
17
17
  try {
18
- typeof clearTimeout == "function" ? u = clearTimeout : u = E;
18
+ typeof clearTimeout == "function" ? f = clearTimeout : f = E;
19
19
  } catch {
20
- u = E;
20
+ f = E;
21
21
  }
22
22
  })();
23
- function _(e) {
24
- if (i === setTimeout)
23
+ function O(e) {
24
+ if (u === setTimeout)
25
25
  return setTimeout(e, 0);
26
- if ((i === b || !i) && setTimeout)
27
- return i = setTimeout, setTimeout(e, 0);
26
+ if ((u === b || !u) && setTimeout)
27
+ return u = setTimeout, setTimeout(e, 0);
28
28
  try {
29
- return i(e, 0);
29
+ return u(e, 0);
30
30
  } catch {
31
31
  try {
32
- return i.call(null, e, 0);
32
+ return u.call(null, e, 0);
33
33
  } catch {
34
- return i.call(this, e, 0);
34
+ return u.call(this, e, 0);
35
35
  }
36
36
  }
37
37
  }
38
- function F(e) {
39
- if (u === clearTimeout)
38
+ function B(e) {
39
+ if (f === clearTimeout)
40
40
  return clearTimeout(e);
41
- if ((u === E || !u) && clearTimeout)
42
- return u = clearTimeout, clearTimeout(e);
41
+ if ((f === E || !f) && clearTimeout)
42
+ return f = clearTimeout, clearTimeout(e);
43
43
  try {
44
- return u(e);
44
+ return f(e);
45
45
  } catch {
46
46
  try {
47
- return u.call(null, e);
47
+ return f.call(null, e);
48
48
  } catch {
49
- return u.call(this, e);
49
+ return f.call(this, e);
50
50
  }
51
51
  }
52
52
  }
53
- var l = [], N = !1, p, y = -1;
54
- function B() {
55
- !N || !p || (N = !1, p.length ? l = p.concat(l) : y = -1, l.length && S());
53
+ var m = [], $ = !1, g, v = -1;
54
+ function C() {
55
+ !$ || !g || ($ = !1, g.length ? m = g.concat(m) : v = -1, m.length && _());
56
56
  }
57
- function S() {
58
- if (!N) {
59
- var e = _(B);
60
- N = !0;
61
- for (var t = l.length; t; ) {
62
- for (p = l, l = []; ++y < t; )
63
- p && p[y].run();
64
- y = -1, t = l.length;
57
+ function _() {
58
+ if (!$) {
59
+ var e = O(C);
60
+ $ = !0;
61
+ for (var t = m.length; t; ) {
62
+ for (g = m, m = []; ++v < t; )
63
+ g && g[v].run();
64
+ v = -1, t = m.length;
65
65
  }
66
- p = null, N = !1, F(e);
66
+ g = null, $ = !1, B(e);
67
67
  }
68
68
  }
69
69
  r.nextTick = function(e) {
@@ -71,12 +71,12 @@ r.nextTick = function(e) {
71
71
  if (arguments.length > 1)
72
72
  for (var n = 1; n < arguments.length; n++)
73
73
  t[n - 1] = arguments[n];
74
- l.push(new A(e, t)), l.length === 1 && !N && _(S);
74
+ m.push(new S(e, t)), m.length === 1 && !$ && O(_);
75
75
  };
76
- function A(e, t) {
76
+ function S(e, t) {
77
77
  this.fun = e, this.array = t;
78
78
  }
79
- A.prototype.run = function() {
79
+ S.prototype.run = function() {
80
80
  this.fun.apply(null, this.array);
81
81
  };
82
82
  r.title = "browser";
@@ -85,17 +85,17 @@ r.env = {};
85
85
  r.argv = [];
86
86
  r.version = "";
87
87
  r.versions = {};
88
- function f() {
88
+ function d() {
89
89
  }
90
- r.on = f;
91
- r.addListener = f;
92
- r.once = f;
93
- r.off = f;
94
- r.removeListener = f;
95
- r.removeAllListeners = f;
96
- r.emit = f;
97
- r.prependListener = f;
98
- r.prependOnceListener = f;
90
+ r.on = d;
91
+ r.addListener = d;
92
+ r.once = d;
93
+ r.off = d;
94
+ r.removeListener = d;
95
+ r.removeAllListeners = d;
96
+ r.emit = d;
97
+ r.prependListener = d;
98
+ r.prependOnceListener = d;
99
99
  r.listeners = function(e) {
100
100
  return [];
101
101
  };
@@ -111,8 +111,8 @@ r.chdir = function(e) {
111
111
  r.umask = function() {
112
112
  return 0;
113
113
  };
114
- var C = O.exports;
115
- const h = /* @__PURE__ */ L(C), U = (e = {}) => ({
114
+ var H = F.exports;
115
+ const h = /* @__PURE__ */ P(H), U = (e = {}) => ({
116
116
  region: e.region || h.env.BUNNY_REGION || "SG",
117
117
  baseHostName: "storage.bunnycdn.com",
118
118
  folderName: e.folderName || h.env.BUNNY_FOLDER_NAME || "",
@@ -124,77 +124,87 @@ const h = /* @__PURE__ */ L(C), U = (e = {}) => ({
124
124
  file: e,
125
125
  buffer: t,
126
126
  folder: n,
127
- ...c
127
+ format: c,
128
+ ...o
128
129
  }) => new Promise(
129
- async (s, a) => {
130
+ async (p, l) => {
130
131
  try {
131
- !t && !e && a({ res: !1, message: "No file uploaded" });
132
- const o = U(c), g = t ? t.length : e.buffer.length, m = o.folderName ? `${o.folderName}/` : "", T = n ? `${n}/` : "", d = `${(/* @__PURE__ */ new Date()).getTime()}.webp`, $ = {
132
+ !t && !e && l({ res: !1, message: "No file uploaded" });
133
+ const s = U(o), y = t ? t.length : e.buffer.length, N = s.folderName ? `${s.folderName}/` : "", a = n ? `${n}/` : "", w = c || "jpg", i = `${(/* @__PURE__ */ new Date()).getTime()}.${w}`, T = {
133
134
  method: "PUT",
134
- hostname: o.region ? `${o.region}.${o.baseHostName}` : o.baseHostName,
135
+ hostname: s.region ? `${s.region}.${s.baseHostName}` : s.baseHostName,
135
136
  port: 443,
136
- path: `/${o.storageZone}/${m}${T}${d}`,
137
+ path: `/${s.storageZone}/${N}${a}${i}`,
137
138
  headers: {
138
- AccessKey: o.password,
139
+ AccessKey: s.password,
139
140
  "Content-Type": "application/octet-stream",
140
- "Content-Length": g.toString()
141
+ "Content-Length": y.toString()
141
142
  }
142
- }, w = await fetch(`https://${$.hostname}${$.path}`, {
143
+ }, A = await fetch(`https://${T.hostname}${T.path}`, {
143
144
  method: "PUT",
144
- headers: $.headers,
145
+ headers: T.headers,
145
146
  body: t || e.buffer
146
147
  });
147
- if (w.status === 201) {
148
- const v = `https://${o.storageZone}.b-cdn.net/${m}${T}${d}`;
149
- s({ res: !0, message: "upload success", url: v });
148
+ if (A.status === 201) {
149
+ const L = `https://${s.storageZone}.b-cdn.net/${N}${a}${i}`;
150
+ p({ res: !0, message: "upload success", url: L });
150
151
  } else
151
- a({ res: !1, message: "Upload failed", error: await w.text() });
152
+ l({ res: !1, message: "Upload failed", error: await A.text() });
152
153
  } catch {
153
- a({ res: !1, message: "Server error" });
154
+ l({ res: !1, message: "Server error" });
154
155
  }
155
156
  }
156
- ), P = async ({ folder: e = "", configOverrides: t = {} } = {}) => new Promise((n, c) => {
157
+ ), Y = async ({ folder: e = "", configOverrides: t = {} } = {}) => new Promise((n, c) => {
157
158
  try {
158
- const s = U(t), a = s.region ? `${s.region}.${s.baseHostName}` : s.baseHostName, o = s.folderName ? `${s.folderName}/` : "", g = e ? `${e}/` : "", m = `https://${a}/${s.storageZone}/${o}${g}`, T = { AccessKey: s.password };
159
- fetch(m, { headers: T }).then((d) => d.json()).then((d) => {
160
- const $ = d.map((w) => {
161
- const v = `https://${s.storageZone}.b-cdn.net/${o}${g}${w.ObjectName}`;
162
- return { ...w, Url: v };
159
+ const o = U(t), p = o.region ? `${o.region}.${o.baseHostName}` : o.baseHostName, l = o.folderName ? `${o.folderName}/` : "", s = e ? `${e}/` : "", y = `https://${p}/${o.storageZone}/${l}${s}`, N = { AccessKey: o.password };
160
+ fetch(y, { headers: N }).then((a) => a.json()).then((a) => {
161
+ const w = a.map((i) => {
162
+ const T = `https://${o.storageZone}.b-cdn.net/${l}${s}${i.ObjectName}`;
163
+ return { ...i, Url: T };
163
164
  });
164
- n({ res: !0, message: "List retrieved successfully", files: $ });
165
- }).catch((d) => {
166
- c({ res: !1, message: "Network error", error: d });
165
+ n({ res: !0, message: "List retrieved successfully", files: w });
166
+ }).catch((a) => {
167
+ c({ res: !1, message: "Network error", error: a });
167
168
  });
168
169
  } catch {
169
170
  c({ res: !1, message: "Server error" });
170
171
  }
171
- }), Y = ({
172
+ }), Z = ({
172
173
  ObjectName: e,
173
174
  href: t,
174
175
  ...n
175
- }) => new Promise((c, s) => {
176
+ }) => new Promise((c, o) => {
176
177
  if (!e && !t) {
177
- s({ res: !1, message: "No file specified for deletion" });
178
+ o({ res: !1, message: "No file specified for deletion" });
178
179
  return;
179
180
  }
180
181
  try {
181
- const a = U(n), o = a.region ? `${a.region}.${a.baseHostName}` : a.baseHostName, g = t ? decodeURIComponent(t.split("/")[t.split("/").length - 1]) : e;
182
- fetch(`https://${o}/${a.storageZone}/${a.folderName}/${g}`, {
182
+ let p = "", l = "";
183
+ if (t) {
184
+ const a = t.split("/").filter((i) => i !== "" && !i.includes("http"));
185
+ if ([...a].pop()?.includes(".") || !1) {
186
+ const i = [...a];
187
+ p = decodeURIComponent(i.pop() || ""), l = i.splice(1, 1).join("/");
188
+ } else
189
+ l = [...a].splice(1, 1).join("/");
190
+ }
191
+ const s = U(n), y = s.region ? `${s.region}.${s.baseHostName}` : s.baseHostName, N = l ? `/${l}` : "";
192
+ fetch(`https://${y}/${s.storageZone}${N}/${p}`, {
183
193
  method: "DELETE",
184
- headers: { AccessKey: a.password }
185
- }).then((m) => {
186
- m.status === 200 ? c({ res: !0, message: "File deleted successfully" }) : c({ res: !1, message: "Failed to delete file" });
187
- }).catch((m) => {
188
- s({ res: !1, message: "Network error", error: m });
194
+ headers: { AccessKey: s.password }
195
+ }).then((a) => {
196
+ a.status === 200 ? c({ res: !0, message: "File deleted successfully" }) : c({ res: !1, message: "Failed to delete file" });
197
+ }).catch((a) => {
198
+ o({ res: !1, message: "Network error", error: a });
189
199
  });
190
200
  } catch {
191
- s({ res: !1, message: "Server error" });
201
+ o({ res: !1, message: "Server error" });
192
202
  }
193
- }), Z = { install: R, upload: D, list: P, deleteFile: Y };
203
+ }), x = { install: R, upload: D, list: Y, deleteFile: Z };
194
204
  export {
195
- Z as default,
196
- Y as deleteFile,
205
+ x as default,
206
+ Z as deleteFile,
197
207
  R as install,
198
- P as list,
208
+ Y as list,
199
209
  D as upload
200
210
  };
package/lib/type.d.ts CHANGED
@@ -20,6 +20,7 @@ export type UploadParams = {
20
20
  file?: Express.Multer.File;
21
21
  buffer?: Buffer;
22
22
  folder?: string;
23
+ format?: 'jpeg' | 'png' | 'webp';
23
24
  };
24
25
  export type ListParams = {
25
26
  folder?: string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "lesca-node-bunnycdn",
3
3
  "private": false,
4
4
  "description": "use bunny CDN api by node",
5
- "version": "0.0.21",
5
+ "version": "0.0.23",
6
6
  "type": "module",
7
7
  "keywords": [
8
8
  "bunnycdn",
@@ -39,7 +39,6 @@
39
39
  "path": "^0.12.7",
40
40
  "prettier": "^3.8.0",
41
41
  "prettier-plugin-tailwindcss": "^0.7.2",
42
- "sharp": "^0.34.5",
43
42
  "tsx": "^4.21.0",
44
43
  "typescript": "^5.9.3",
45
44
  "typescript-eslint": "^8.53.0",
package/readme.md CHANGED
@@ -281,16 +281,7 @@ export const handler = async (event, context) => {
281
281
 
282
282
  ## Features
283
283
 
284
- - Upload files to BunnyCDN storage
285
- - ✅ List files in storage zone
286
- - ✅ Delete files from storage
287
- - ✅ Support for different regions
288
- - ✅ Folder organization
289
- - ✅ Full TypeScript support
290
- - ✅ Environment variable configuration
291
- - ✅ Automatic file extension handling (.webp)
292
- - ✅ UUID-based filename generation
293
- - ✅ Perfect for serverless functions
284
+ - maintain if necessary
294
285
 
295
286
  ## License
296
287
 
@@ -299,7 +290,3 @@ MIT
299
290
  ## Contributing
300
291
 
301
292
  Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
302
-
303
- ### Features
304
-
305
- - maintain if necessary