Skip to content

Extract API endpoint magic strings into constants - #685

Merged
arii merged 2 commits into
leaderfrom
copilot/extract-api-endpoints-constants
Dec 1, 2025
Merged

Extract API endpoint magic strings into constants#685
arii merged 2 commits into
leaderfrom
copilot/extract-api-endpoints-constants

Conversation

Copilot AI commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Description

Extracts hardcoded API endpoint paths from client-side fetch calls into a centralized constants/apiEndpoints.ts file.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactor (code change that neither fixes a bug nor adds a feature)
  • ⚡ Performance improvement
  • 🧪 Test addition or update

Changes Made

  • Created constants/apiEndpoints.ts with named constants for all API endpoints
  • Updated 9 files to import and use endpoint constants instead of magic strings
  • Added constants/ to lint script in package.json

New constants:

export const API_SPOTIFY_PLAYLISTS = '/api/spotify/playlists'
export const API_SPOTIFY_DEVICES = '/api/spotify/devices'
export const API_SPOTIFY_ACCESS_TOKEN = '/api/spotify/access-token'
export const API_DEBUG_RESET = '/api/debug/reset'
export const API_DEBUG_SPOTIFY_TOKEN = '/api/debug/spotify-token'
export const API_INTERNAL_TOKEN_DELIVERY = '/api/internal/token-delivery'

Note: middleware.ts retains hardcoded paths in config.matcher — Next.js requires static strings for build-time analysis.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Visual regression tests passed
  • Manual testing completed

Screenshots (if applicable)

N/A - refactor only, no UI changes.

Checklist

  • My code follows the project style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Related Issues

Closes #25

Additional Notes

The original issue referenced src/services/api.ts which doesn't exist in this repo. Adapted to extract endpoints from actual client-side fetch calls across components, hooks, and pages.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/hrm/hrm/node_modules/.bin/next build (dns block)
  • scarf.sh
    • Triggering command: /usr/local/bin/node node ./report.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Extract API endpoint magic strings from src/services/api.ts</issue_title>
<issue_description>Identify all hardcoded API endpoint paths (e.g., /api/v1/users, /api/v1/data) within src/services/api.ts. Extract these into a dedicated src/constants/apiEndpoints.ts file as named constants. Update src/services/api.ts to use these new constants.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: arii <342438+arii@users.noreply.github.com>
Copilot AI changed the title [WIP] Extract API endpoint magic strings into constants file Extract API endpoint magic strings into constants Dec 1, 2025
Copilot AI requested a review from arii December 1, 2025 08:02
@arii
arii marked this pull request as ready for review December 1, 2025 08:37
@arii
arii merged commit 9e4fa9b into leader Dec 1, 2025
4 checks passed
@arii
arii deleted the copilot/extract-api-endpoints-constants branch December 1, 2025 08:37
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

Successfully merging this pull request may close these issues.

Extract API endpoint magic strings from src/services/api.ts [P1] Architecture: useWebSocket hook creates multiple connections instead of a singleton

2 participants