Skip to content

Commit b9b1ab4

Browse files
committed
add wrangler.toml
1 parent ec14378 commit b9b1ab4

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,32 @@ The API is implemented as a Cloudflare Worker and uses several KS namespaces tha
4141

4242
## Contributing
4343

44+
### KV namespaces
45+
46+
As listed in the wrangler.toml:
47+
48+
- `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.
49+
50+
Each entry contains top-level metadata such as package name, author, description, how to autoupdate (from npm or git), etc.
51+
52+
This metadata is the same as the files in cdnjs/packages, except it contains a few additional properties such as the latest version.
53+
54+
- `CDNJS_VERSIONS`: A metadata entry for each of the ~120K versions.
55+
56+
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).
57+
58+
- `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.
59+
60+
To avoid the KV value limit, each value is compressed with gzip.
61+
62+
- `CDNJS_SRIS`: SRIs for each of the uncompressed JavaScript and CSS files in cdnjs.
63+
64+
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.
65+
66+
By listing this namespace by prefix, we can easily fetch the SRIs in bulks of 1000.
67+
68+
This will eventually replace cdnjs/SRIs.
69+
4470
### Deployement
4571

4672
Deployement and testing is managed by Cloudflare for now.

wrangler.toml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name = "api-worker"
2+
type = "webpack"
3+
account_id = ""
4+
workers_dev = true
5+
6+
kv_namespaces = [
7+
{ binding = "CDNJS_PACKAGES", preview_id = "a" },
8+
{ binding = "CDNJS_VERSIONS", preview_id = "a" },
9+
{ binding = "CDNJS_AGGREGATED_METADATA", preview_id = "a" },
10+
{ binding = "CDNJS_SRIS", preview_id = "a" }
11+
]
12+
13+
[vars]
14+
ENV = "dev"
15+
SENTRY_DSN = ""

0 commit comments

Comments
 (0)