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

Consider using ungh to remove GitHub API limit #305

Open
hacknug opened this issue May 21, 2024 · 5 comments
Open

Consider using ungh to remove GitHub API limit #305

hacknug opened this issue May 21, 2024 · 5 comments

Comments

@hacknug
Copy link

hacknug commented May 21, 2024

Not a bug
Consider using ungh to get rid of the GitHub API limitations.

Not sure if there's anything else that would need changing besides the two URLs that point to their API:

private const string RELEASES = "https://api.github.com/repos/{0}/{1}/releases";
private const string CONTENTS = "https://api.github.com/repos/{0}/{1}/contents/{2}";

I checked the repo and didn't see any tests to ensure that's the only change required and nothing breaks.

I can open a PR with the change if it helps but I wanted to open this issue to discuss if it would be a good idea first.

@mattpannella
Copy link
Owner

i took a quick look at this, but it looks like it's still in development, and doesn't supply all of the info that the official github endpoints do (unless i am missing something)
example: the releases endpoint only has this in the response:

{
  "releases": [
    {
      "id": 82066265,
      "tag": "v3.0.0-rc.13",
      "author": "pi0",
      "name": "v3.0.0-rc.13",
      "draft": false,
      "prerelease": false,
      "createdAt": "2022-11-04T11:37:49Z",
      "publishedAt": "2022-11-04T11:41:59Z",
      "markdown": "....",
      "html": "..."
    }
  ]
}

but we rely on the assets array in the regular github endpoint that find the files and download urls for them

[
  {
    "url": "https://api.github.com/repos/octocat/Hello-World/releases/1",
    "html_url": "https://github.com/octocat/Hello-World/releases/v1.0.0",
    "assets_url": "https://api.github.com/repos/octocat/Hello-World/releases/1/assets",
    "upload_url": "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}",
    "tarball_url": "https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0",
    "zipball_url": "https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0",
    "id": 1,
    "node_id": "MDc6UmVsZWFzZTE=",
    "tag_name": "v1.0.0",
    "target_commitish": "master",
    "name": "v1.0.0",
    "body": "Description of the release",
    "draft": false,
    "prerelease": false,
    "created_at": "2013-02-27T19:35:32Z",
    "published_at": "2013-02-27T19:35:32Z",
    "author": {
      "login": "octocat",
      "id": 1,
      "node_id": "MDQ6VXNlcjE=",
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "assets": [
      {
        "url": "https://api.github.com/repos/octocat/Hello-World/releases/assets/1",
        "browser_download_url": "https://github.com/octocat/Hello-World/releases/download/v1.0.0/example.zip",
        "id": 1,
        "node_id": "MDEyOlJlbGVhc2VBc3NldDE=",
        "name": "example.zip",
        "label": "short description",
        "state": "uploaded",
        "content_type": "application/zip",
        "size": 1024,
        "download_count": 42,
        "created_at": "2013-02-27T19:35:32Z",
        "updated_at": "2013-02-27T19:35:32Z",
        "uploader": {
          "login": "octocat",
          "id": 1,
          "node_id": "MDQ6VXNlcjE=",
          "avatar_url": "https://github.com/images/error/octocat_happy.gif",
          "gravatar_id": "",
          "url": "https://api.github.com/users/octocat",
          "html_url": "https://github.com/octocat",
          "followers_url": "https://api.github.com/users/octocat/followers",
          "following_url": "https://api.github.com/users/octocat/following{/other_user}",
          "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
          "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
          "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
          "organizations_url": "https://api.github.com/users/octocat/orgs",
          "repos_url": "https://api.github.com/users/octocat/repos",
          "events_url": "https://api.github.com/users/octocat/events{/privacy}",
          "received_events_url": "https://api.github.com/users/octocat/received_events",
          "type": "User",
          "site_admin": false
        }
      }
    ]
  }
]

@hacknug
Copy link
Author

hacknug commented Oct 17, 2024

There's been no traction on the issue I opened but a couple months ago a PR was merged that added assets to the releases endpoint.

Was this the only thing missing or is there something else that we would still need to make the change?

PR: unjs/ungh#100
Example: https://ungh.cc/repos/mattpannella/pupdate/releases

@mattpannella
Copy link
Owner

hm, just quickly looking this might be all I need. I'll take a closer look later

@mattpannella
Copy link
Owner

they seem to be including the data we need, but the structure of the json payload doesn't exact match what github's api returns, so i'd need to update the models (and maybe a few other things?) in order to switch over to this.
i was hoping it could be an in place swap and add a setting to allow toggling between github's native api and this proxy, because i don't want to rely on this service and have it go down and then need to push updates to the application

@hacknug
Copy link
Author

hacknug commented Nov 20, 2024

I wouldn't worry about ungh going down but since they state on the roadmap that the api could change (https://github.com/unjs/ungh?tab=readme-ov-file#roadmap) it might be better to hold off (at least) until it is marked as stable.

Feel free to close the issue as you see fit 👍

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

No branches or pull requests

2 participants