Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: github driver #61

Merged
merged 6 commits into from
Jun 13, 2022
Merged

feat: github driver #61

merged 6 commits into from
Jun 13, 2022

Conversation

farnabaz
Copy link
Collaborator

@farnabaz farnabaz commented Jun 9, 2022

Create Github driver using Github API and raw CDN

  • Use API to fetch files
  • Use Github raw CDN to fetch file content
  • Cache files to 10 minutes (configurable by ttl)
  • Accept dir to load contents from specific directory

src/drivers/github.ts Show resolved Hide resolved
const prefix = withTrailingSlash(dir)
const files = {}
try {
const tree = await $fetch(`https://api.github.com/repos/${org}/${repo}/git/trees/${branch}?recursive=1`, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a global const (GITHUB_URL) + an option to customize.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later improvement: We can expose storage instance to the driver and support cachePath so that github driver can permanently cache this.

src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Outdated Show resolved Hide resolved
src/drivers/github.ts Show resolved Hide resolved
@pi0
Copy link
Member

pi0 commented Jun 9, 2022

@farnabaz Adding to the docs would be nice also mentioning driver usage and behavior. You can use yarn doctoc to update TOC.

@pi0 pi0 changed the title feat(github-driver): create Github driver using Github api and raw CDN feat: github driver Jun 13, 2022
@pi0 pi0 merged commit 5ddb41a into unjs:main Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants