BunnyCDN node bindings
This was initially planned to be a simple utility for us to use to update js files on Bunny's storage platform and then bust their cache after a deployment.
$ npm install bunnycdn-node
set the following environment variables
- BUNNY_API_KEY
- BUNNY_STORAGE_API_KEY
import { Bunny } from 'bunnycdn-node';
...
const bunny = new Bunny();
All files in Storage Zone
const files: StorageZoneFile[] = await bunny.storage.get('mystoragezone');
Contents of specific file
const fileContents: string = await bunny.storage.getFile('mystoragezone/somepath/afile.js');
Update Contents of specific file
bunny.storage.update('mystorage/somepath/afile.js', 'console.log(\'I was updated\');');
Delete specific file
bunny.storage.delete('mystorage/somepath/afile.js');
Get Billing
const billing: Billing = await bunny.billing();
Get Statistics
const stats : Statistic = await bunny.statistics();
Purge File Cache
bunny.purge('http://my-zone/mypath/filetopurge.css');
HardUpdate File (Update and Purge)
bunny.hardUpdate('https://mydomain.com','myStorage', 'myPath', 'fileName.css', 'new file contents');