cdnjs / api-worker

The edge worker that provides KV metadata to the cdnjs API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

< cdnjs >

The #1 free and open source CDN built to make life easier for developers.


Introduction

This is the code that powers metadata.speedcdnjs.com. It's an internal API that is NOT meant to be used directly. See API instead.

The API is implemented as a Cloudflare Worker and uses several KV namespaces that are populated from the cdnjs bot.

Contributing

KV namespaces

As listed in the wrangler.toml:

  • CDNJS_PACKAGES: A metadata entry for each of the ~4K packages containing the same properties as the legacy package.json files in cdnjs/cdnjs's GitHub repo.

Each entry contains top-level metadata such as package name, author, description, how to autoupdate (from npm or git), etc.

This metadata is the same as the files in cdnjs/packages, except it contains a few additional properties such as the latest version.

  • CDNJS_VERSIONS: A metadata entry for each of the ~120K versions.

Each entry contains the list of uncompressed file names for that particular version. This list includes the any autogenerated files by the bot, such as minified JavaScript (.min.js) and CSS (.min.css).

  • CDNJS_AGGREGATED_METADATA: A metadata entry for each package, consisting of the top-level package metadata from CDNJS_PACKAGES and all version metadata belonging to the respective package in CDNJS_VERSIONS.

To avoid the KV value limit, each value is compressed with gzip.

  • CDNJS_SRIS: SRIs for each of the uncompressed JavaScript and CSS files in cdnjs.

Each SRI is a sha512 hash of each file's uncompressed content, and it is stored in the KV metadata associated with each entry. There is no KV value.

By listing this namespace by prefix, we can easily fetch the SRIs in bulks of 1000.

This will eventually replace cdnjs/SRIs.

Deployment

Deployment and testing is managed by Cloudflare for now.

License

Each library hosted on cdnjs is released under its own license. This cdnjs repository is published under MIT license.

About

The edge worker that provides KV metadata to the cdnjs API

License:MIT License


Languages

Language:JavaScript 100.0%