0.1.3 • Published 4 years ago
@intelrug/bunnycdn v0.1.3
@intelrug/bunnycdn
Install
$ yarn add @intelrug/bunnycdn
Usage
import
import { BunnyCDN } from '@intelrug/bunnycdn';
...
const bunny = new BunnyCDN({
apiAccessKey: 'your-key',
storageZones: [{
name: 'your-storage-zone-name',
accessKey: 'your-storage-zone-access-key'
}],
});
...
Storage
All files in Storage Zone
const files: StorageZoneFile[] = await bunny.storage.get('your-storage-zone-name');
Get contents of specific file
const fileContents: string = await bunny.storage
.getFile('your-storage-zone-name', 'somepath/script.js');
Create a file or update contents of specific file
bunny.storage.update(
'your-storage-zone-name',
'somepath/script.js',
'console.log(\'I was updated\');'
);
Delete specific file
bunny.storage.delete('your-storage-zone-name', 'somepath/script.js');
Bunny API
Get Billing
const billing: Billing = await bunny.billing();
Get Statistics
const stats : Statistic = await bunny.statistics();
Purge File Cache
bunny.purge('http://your-zone/somepath/filetopurge.css');
HardUpdate File (Update and Purge)
bunny.hardUpdate(
'https://your-domain.com',
'your-storage',
'somepath',
'fileName.css',
'new file contents'
);