Generalize code platform base API URL#95
Conversation
Step toward supporting Codeberg and GitLab
There was a problem hiding this comment.
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_URLto 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.yamlandREADME.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.
| 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'); |
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Applied in commit 396573b. Changes made:
src/validateConfig.js:GIT_API_BASE_URLis 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 missingGIT_API_BASE_URL = CONFIG.GIT_API_BASE_URLassignment (fixing theundefinedruntime 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.
There was a problem hiding this comment.
@copilot, don't we have the same potential trailing slash issue with the API_BASE_URL for Hugging Face?
There was a problem hiding this comment.
Yes, the same issue applied. Fixed in commit 9a81743 — API_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.
… typo, clarify README Agent-Logs-Url: https://github.com/Imageomics/catalog/sessions/8c63fcd7-d8ba-4c1f-a67d-0bef7a363ffe Co-authored-by: egrace479 <38985481+egrace479@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Imageomics/catalog/sessions/8c63fcd7-d8ba-4c1f-a67d-0bef7a363ffe Co-authored-by: egrace479 <38985481+egrace479@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Imageomics/catalog/sessions/ed270878-c7cd-492c-8a61-3ba22b5e63f2 Co-authored-by: egrace479 <38985481+egrace479@users.noreply.github.com>
|
Closing in favor of implementation in #97. |
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.jsand the workflow itself which are likely best left to users of those platforms.