/bunnycdn

A NodeJS SDK for Bunny.Net CDN. 🧪

Primary LanguageTypeScript

@8ctopotamus/bunnycdn

A NodeJS SDK for Bunny.Net CDN.

Bunny.net hero banner graphic

The properties and methods mirror the endpoints described in the BunnyCDN API Documentation.

âš  IMPORTANT: This package not anywhere near ready for use in actual projects. At this point it is an exercise in building an NPM package with TypeScript.

Usage

import BunnyCDN from '@8ctopotamus/bunnycdn'

// configure the SDK
const bunny = new BunnyCDN({
  pullzone: process.env.BUNNY_NET_PULLZONE,
  accessKey: process.env.BUNNY_NET_ACCESS_KEY,
  storageZoneName: process.env.BUNNY_NET_STORAGEZONE_NAME,
  storageZonePassword: process.env.BUNNY_NET_STORAGEZONE_PASSWORD,
  storageZoneRegion: process.env.BUNNY_NET_STORAGEZONE_REGION, // may be excluded if not applicable
})

Edge Storage API

List folders and files at a given storage path

await bunny.storage.list('images')

Upload a file

const url = await bunny.storage.upload(`./img.jpg`, `images/img.jpg`)

Download a file

await bunny.storage.download(`images/img.jpg`, `./img.jpg`)

Delete a file

await bunny.storage.delete(`images/img.jpg`)

Develop

Create and fill out a .env file in the root of the project:

BUNNY_NET_PULLZONE=your_pullzone_name
BUNNY_NET_ACCESS_KEY=your_access_key
BUNNY_NET_STORAGEZONE_NAME=your_storagezone_name
BUNNY_NET_STORAGEZONE_PASSWORD=your_storagezone_password
BUNNY_NET_STORAGEZONE_REGION=your_storagezone_region_if_exists

Run npm run dev and npm run test in separate terminals

TODOs

Bunny.Net API

  • Abuse Case
  • Countries
  • Billing
  • Compute
  • Support
  • DRM Certificate
  • Region
  • Stream Video Library
  • DNS Zone
  • [...] Pull Zone
  • Purge
  • Statistics
  • Storage Zone
  • User

Stream API

  • Manage Collections

    • Get Collection
    • Update Collection
    • Delete Collection
    • Get Collection List
    • Create Collection
  • Manage Videos

    • Get Videoget
    • Update Videopost
    • Delete Videodelete
    • Upload Videoput
    • Get Video Heatmapget
    • Get Video Statisticsget
    • Reencode Videopost
    • List Videosget
    • Create Videopost
    • Set Thumbnailpost
    • Fetch Videopost
    • Add Captionpost
    • Delete Caption

Inspirations

Helpful links for me