Skip to content

TypeScript API / laikacms/storage/github-cdn / GithubCdnDataSource

Class: GithubCdnDataSource ​

Constructors ​

Constructor ​

ts
new GithubCdnDataSource(opts): GithubCdnDataSource;

Parameters ​

ParameterType
optsGithubCdnDataSourceOptions

Returns ​

GithubCdnDataSource

Methods ​

getFileContents() ​

ts
getFileContents(relativePath): Promise<LaikaResult<{
  content: string;
  path: string;
  sha: string;
}>>;

Fetch a file's content from the CDN plus a computed git blob sha.

Parameters ​

ParameterType
relativePathstring

Returns ​

Promise<LaikaResult<{ content: string; path: string; sha: string; }>>


getFileMeta() ​

ts
getFileMeta(relativePath): Promise<LaikaResult<{
  createdAt: Date;
  sha: string;
  updatedAt: Date;
}>>;

Metadata for a file. Existence is resolved from the file tree. Timestamps are always epoch(0). The sha depends on the GithubCdnDataSourceOptions.fetchMeta flag.

Parameters ​

ParameterType
relativePathstring

Returns ​

Promise<LaikaResult<{ createdAt: Date; sha: string; updatedAt: Date; }>>


listDirectory() ​

ts
listDirectory(relativePath): Promise<LaikaResult<GithubDirEntry[]>>;

List immediate children of a directory. Empty array when the directory is missing or empty.

Parameters ​

ParameterType
relativePathstring

Returns ​

Promise<LaikaResult<GithubDirEntry[]>>


pathType() ​

ts
pathType(relativePath): Promise<"dir" | "file">;

Distinguish file vs dir. Throws NotFoundError for missing paths (mirrors GithubDataSource).

Parameters ​

ParameterType
relativePathstring

Returns ​

Promise<"dir" | "file">

Released under the MIT License.