Skip to content

TypeScript API / contentia/storage/github-cdn / GithubCdnDataSourceOptions

Type Alias: GithubCdnDataSourceOptions ​

ts
type GithubCdnDataSourceOptions = object;

Read-only I/O against a public GitHub repository, served entirely from CDNs — no GitHub App, no OAuth, no API token, and no @octokit/* dependency.

  • Content comes from jsDelivr's file CDN (cdn.jsdelivr.net/gh).
  • Directory listings come from jsDelivr's metadata API (data.jsdelivr.com), which returns the repo's full file tree as JSON.

The trade-off versus "contentia/storage-github".GithubDataSource is metadata: a CDN carries no git history, so commit timestamps are always epoch(0). See GithubCdnDataSourceOptions.fetchMeta for the sha/revision behavior.

Freshness note: CDN responses are cached (jsDelivr caches a ref for hours), so this is best suited to serving mostly-static public content, not live editing.

Properties ​

branch? ​

ts
branch?: string;

Branch, tag, or commit sha jsDelivr can resolve. Defaults to the repo's default branch.


cdnBaseUrl? ​

ts
cdnBaseUrl?: string;

Override the content CDN base. Default: https://cdn.jsdelivr.net/gh.


dataApiBaseUrl? ​

ts
dataApiBaseUrl?: string;

Override the metadata/tree API base. Default: https://data.jsdelivr.com/v1/packages/gh.


fetch? ​

ts
fetch?: typeof fetch;

Injectable fetch (tests, custom agents). Defaults to the global fetch.


fetchMeta? ​

ts
fetchMeta?: boolean;

Controls how much work GithubCdnDataSource.getFileMeta does to produce a revisionId (sha). Timestamps are epoch(0) either way — the CDN has no history.

  • false (default): no extra request. The sha is jsDelivr's content hash from the already-loaded file tree (empty string if the tree omits it).
  • true: downloads the file to compute a canonical git blob sha, matching the sha that GithubCdnDataSource.getFileContents returns. Costs one fetch per metadata lookup.

owner ​

ts
owner: string;

repo ​

ts
repo: string;

userAgent? ​

ts
userAgent?: string;

User-Agent sent on all requests.