Skip to content

Generalize code platform base API URL#95

Closed
egrace479 wants to merge 5 commits into
mainfrom
feat/generalize-code-platform
Closed

Generalize code platform base API URL#95
egrace479 wants to merge 5 commits into
mainfrom
feat/generalize-code-platform

Conversation

@egrace479
Copy link
Copy Markdown
Member

Step toward supporting Codeberg and GitLab (ref: #93).

I think the Codeberg API URL can just be swapped in here in place of the GitHub API URL, but it hasn't been tested yet, so this is just opening that door by generalizing the URL in a structure that should also work for Codeberg. Hence, the "in development" note at that line of the config file.

I'm sticking with a single base URL because GitLab has some other parameters that seem to be required for implementation that would require other changes at the API calls better suited to a separate line of code commented out to be switched. Both other platforms would require changes in the "Fetch helpers" section of scripts/export-tags.js and the workflow itself which are likely best left to users of those platforms.

Step toward supporting Codeberg and GitLab
@egrace479 egrace479 requested review from EmersonFras and Copilot May 11, 2026 17:58
@egrace479 egrace479 added the enhancement New feature or request label May 11, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a configurable Git-platform API base URL (GIT_API_BASE_URL) so the catalog can be pointed at GitHub-compatible services (a step toward supporting Codeberg/GitLab per #93), instead of hard-coding https://api.github.com/.

Changes:

  • Add GIT_API_BASE_URL to config validation and tests.
  • Replace hard-coded GitHub API URLs with ${GIT_API_BASE_URL}... in the frontend and build/dev scripts.
  • Document the new config option in public/config.yaml and README.md.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/validateConfig.test.js Adds GIT_API_BASE_URL to the valid config fixture and asserts it’s required.
src/validateConfig.js Requires GIT_API_BASE_URL in config validation.
scripts/fetch-releases.js Uses CONFIG.GIT_API_BASE_URL when fetching org repos and latest releases.
scripts/export-tags.js Uses GIT_API_BASE_URL for org/repo API calls and updates the header comment.
README.md Documents the new GIT_API_BASE_URL configuration setting.
public/config.yaml Adds GIT_API_BASE_URL with explanatory comments and a GitHub default.
main.js Switches GitHub API calls to use GIT_API_BASE_URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main.js
Comment thread src/validateConfig.js Outdated
Comment on lines 19 to 21
if (!config.CATALOG_REPO_NAME) errors.push('CATALOG_REPO_NAME');
if (!config.GIT_API_BASE_URL) errors.push('GIT_API_BASE_URL');
if (!config.API_BASE_URL) errors.push('API_BASE_URL');
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Applied in commit 396573b. Changes made:

  • src/validateConfig.js: GIT_API_BASE_URL is now validated as a non-empty string; if present but missing the trailing /, a specific error 'GIT_API_BASE_URL must end with "/"' is returned instead of the generic field-missing error.
  • main.js: Added the missing GIT_API_BASE_URL = CONFIG.GIT_API_BASE_URL assignment (fixing the undefined runtime bug), added it to the fallback default CONFIG, and added defensive trailing-slash normalization.
  • tests/validateConfig.test.js: Added tests for empty string, missing trailing slash, and valid URL with trailing slash.
  • Also fixed the "Codberg" → "Codeberg" typo (scripts/export-tags.js) and updated the README description to clarify the base URL requires a trailing slash.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot, don't we have the same potential trailing slash issue with the API_BASE_URL for Hugging Face?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, the same issue applied. Fixed in commit 9a81743API_BASE_URL now gets the same treatment: validated for a trailing slash in validateConfig.js (with a specific error 'API_BASE_URL must end with "/"' when missing), defensive normalization at assignment time in main.js, updated README description, and added tests for empty string, missing slash, and valid URL cases.

Comment thread scripts/export-tags.js Outdated
Comment thread README.md Outdated
@egrace479 egrace479 removed the request for review from EmersonFras May 11, 2026 18:15
Copilot AI and others added 2 commits May 11, 2026 18:23
@egrace479
Copy link
Copy Markdown
Member Author

Closing in favor of implementation in #97.

@egrace479 egrace479 closed this May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants