ReVanced / revanced-releases-api

🚀 JSON API for ReVanced Releases
https://releases.revanced.app
GNU Affero General Public License v3.0
78 stars 17 forks source link

feat: add cdn related endpoints #15

Closed alexandreteles closed 1 year ago

alexandreteles commented 1 year ago

Is your feature request related to a problem? Please describe.

We want to stop using GH as a CDN. For that purpose, revanced/revanced-cdn-action is being constructed in order to upload our assets into Filecoin so they can be distributed on our manager.

Describe the solution you'd like

The following endpoints/methods should be implemented:

GET /cdn/{org}/{repo}/{version} → Returns asset information (Non-authenticated)
  ↳ Returns 200 if retrieved successufully
  ↳ Returns 404 if asset doesn't exist

POST /cdn/{org}/{repo}/{version} → Stores asset information (Authenticated)
   ↳ Returns 201 if created successfully

PUT /cdn/{org}/{repo}/{version} → Changes asset information (Authenticated)
  ↳ Returns 200 if changed successfully

DEL /cdn/{org}/{repo}/{version} → Deletes asset information (Authenticated)
  ↳ Returns 200 if deleted successfully

The response body for GET /cdn/{org}/{repo}/{version} should follow:

{
  "repository": "string",
  "version": "string",
  "cid": "string",
  "filenames": [
    "filename.ext",
    "filename.ext",
    "filename.ext"
  ]
}

The request body for POST /cdn/{org}/{repo}/{version} and should follow:

{
  "cid": "string",
  "filenames": [
    "filename.ext",
    "filename.ext",
    "filename.ext"
  ]
}

The request body for PUT /cdn/{org}/{repo}/{version} should follow:

{
  "cid": "string",
  "filenames": [
    "filename.ext",
    "filename.ext",
    "filename.ext"
  ]
}

By the own nature of how data is stored and addressed using the IPFS+Filecoin pair the API will not allow for partial changes to stored data, so make sure to post the entire dataset to when doing PUT operations.

In the future we should consider implementing proper IPNS support for this operation although we do not believe mutable data on IPFS/Filecoin will be necessary any time soon.

Data will be stored on Redis using the following standard:

KEY   {org}/{repo}/{version}
VALUE JSONObject

The stored information will be used to enrich other endpoints' outputs like /tools that can now include IPFS adresses like:

{
  "mirrors": {
    "filecoin": {
      "ipfs": "ipfs://{cid}/{filename.ext}"
      "w3s": "https://{cid}.ipfs.w3s.link/{filename.ext}"
    }
   "r2": {
     "url": "https://cdn.rvcd.win/{org}/{repo}/{version}/{filename.ext}"
   }
  }
}

Describe alternatives you've considered None.

Additional context None.

alexandreteles commented 1 year ago

Solved by #17. Please refer to the API documentation that check the final implementation.