NoahStolk / ddinfo-tools

Cross-platform Devil Daggers modding tools, practice tools, and custom leaderboards client
https://devildaggers.info/
MIT License
10 stars 1 forks source link

Compute and expose hash values for mod files #98

Closed rpdelaney closed 1 month ago

rpdelaney commented 1 month ago

What

  1. Compute a hash value for each mod file available for download on the website.
  2. Update the /api/mods/{id} endpoint to include the computed hash value in its response.
  3. Add a new endpoint /api/mods/by-hash to allow searching for mods by their hash value.

Why

Including a hash value for each mod file ensures data integrity and allows users to identify authorship of mod files that have been renamed locally. Additionally, providing a search endpoint by hash value enhances the usability of the API by enabling users to quickly locate specific mod files based on their hash.

Acceptance Criteria

  1. Hash Computation:

    • A hash value (e.g., MD5, SHA-1) is computed for each mod file available for download. The hash value should be computed and stored at the time of file upload or when the mod file is first made available for download.
    • Hash values for previously uploaded files are computed retroactively.
  2. Update /api/mods/{id}:

    • The /api/mods/{id} endpoint includes the computed hash value in its JSON response.
    • Example response:
      {
      "id": 123,
      "name": "ModName",
      "author": "AuthorName",
      "version": "1.0.0",
      "downloadUrl": "https://example.com/mods/123/download",
      "hash": "abc123def4567890abc123def4567890"
      }
  3. Add /api/mods/by-hash:

    • A new endpoint /api/mods/by-hash is created.
    • The endpoint accepts a query parameter hash and returns the mod details if a mod with the specified hash exists.
    • Example request: GET /api/mods/by-hash?hash=abc123def4567890abc123def4567890
rpdelaney commented 1 month ago

Wrong repo. Reposted the issue over here: https://github.com/NoahStolk/ddinfo-web/issues/648