This Cloudflare Worker serves @brika/schema schema files from schema.brika.dev, proxying requests to npm CDN (unpkg/jsdelivr).
Purpose: Display schema files from the @brika/schema npm package, e.g., https://schema.brika.dev/0.1.0/plugin.schema.json
- Version Range Resolution: Supports semver ranges (e.g.,
^0.1.1,~0.1.0,>=0.1.0) - Version Listing:
/versions.jsonendpoint lists all available stable versions - Latest Version:
/latestendpoint redirects to the latest stable version - Exact Versions: Direct version access (e.g.,
/0.1.1/plugin.schema.json) - Pre-release Filtering: Automatically filters out pre-release versions for range resolution
- CORS Support: Adds CORS headers for browser access
cd apps/schema-cdn
bun devThe worker will start on http://localhost:8787 (configurable in wrangler.toml).
# List all available versions
curl http://localhost:8787/versions.json
# Get latest version
curl http://localhost:8787/latest/package.json
# Use version range (resolves to latest matching version)
curl http://localhost:8787/^19.2.0/package.json
curl http://localhost:8787/~19.2.0/package.json
curl http://localhost:8787/>=19.0.0/package.json
# Use exact version
curl http://localhost:8787/19.2.3/package.json- Cloudflare account (free tier works)
- Wrangler CLI installed (or use
bunx wrangler)
cd apps/schema-cdn
bun deployOr using wrangler directly:
cd apps/schema-cdn
bunx wrangler deploy- Go to Cloudflare Dashboard
- Navigate to Workers & Pages
- Select your worker (
brika) - Go to Triggers tab
- Click Add Custom Domain
- Enter:
schema.brika.dev - Click Add Custom Domain
Configure in wrangler.toml:
[vars]
NPM_PACKAGE = "@brika/schema" # npm package name
SCHEMAS_PATH = "/dist" # Path to schemas in package
CDN_PROVIDER = "unpkg" # Options: "unpkg" or "jsdelivr"
CACHE_MAX_AGE = 3600 # Cache max age in secondsThe worker:
- Receives requests to
schema.brika.dev - Parses version/range from the URL path
- If range: queries npm registry to find matching stable version
- Constructs CDN URL:
{cdn}/npm/{package}@{version}{path}/{file} - Proxies request to CDN (unpkg or jsdelivr)
- Adds CORS headers for browser access
- Returns the schema/file
| Request | Description |
|---|---|
/versions.json |
List all available stable versions |
/latest/{file} |
Redirects to latest stable version |
/^0.1.1/{file} |
Resolves to latest version matching ^0.1.1 |
/~0.1.0/{file} |
Resolves to latest version matching ~0.1.0 |
/>=0.1.0/{file} |
Resolves to latest version matching >=0.1.0 |
/0.1.1/{file} |
Direct access to exact version |
# List all versions
curl https://schema.brika.dev/versions.json
# Get latest schema file
curl https://schema.brika.dev/latest/plugin.schema.json
# Get schema file for version range
curl https://schema.brika.dev/^0.1.1/plugin.schema.json
# Get specific version schema file
curl https://schema.brika.dev/0.1.0/plugin.schema.jsonFree tier includes:
- 100,000 requests per day
- Unlimited bandwidth
- Global edge network
For schema hosting, you'll use < 1% of the free quota.
- Framework: Hono (lightweight, fast router for Cloudflare Workers)
- Language: TypeScript
- Package Manager: Bun
- Structure:
worker.ts- Entry pointsrc/routes.ts- Route definitionssrc/utils.ts- Utility functions (version parsing, CDN URLs, etc.)src/types.ts- TypeScript types