asteroid/docs/FRONTEND-API-UPDATES-2025-1...

3.1 KiB

Frontend API URL Updates - 2025-10-08

Overview

Updated all frontend JavaScript files to use the new Radiance define-api endpoint URLs.

URL Changes

Old Format

/asteroid/api/<endpoint>

New Format

/api/asteroid/<endpoint>

Files Updated

auth-ui.js

  • /asteroid/api/auth-status/api/asteroid/auth-status

front-page.js

  • /asteroid/api/icecast-status/api/asteroid/icecast-status

admin.js

  • /asteroid/api/player-status/api/asteroid/player/status

player.js (Multiple Updates)

  • /asteroid/api/tracks/api/asteroid/tracks
  • /api/play?track-id=${id}/api/asteroid/player/play?track-id=${id}
  • /asteroid/api/playlists/create/api/asteroid/playlists/create
  • /asteroid/api/playlists/api/asteroid/playlists
  • /asteroid/api/playlists/${id}/api/asteroid/playlists/get?playlist-id=${id} (Note: Changed from URI pattern to query parameter)
  • /asteroid/api/playlists/add-track/api/asteroid/playlists/add-track
  • /asteroid/api/icecast-status/api/asteroid/icecast-status

Important Changes

Playlist Get Endpoint

The playlist retrieval endpoint changed from a URI pattern to a query parameter:

Old: GET /asteroid/api/playlists/123 New: GET /api/asteroid/playlists/get?playlist-id=123

This aligns with Radiance's define-api pattern where parameters are passed as GET/POST variables rather than URI patterns.

Files Not Updated

users.js

This file contains API calls to user management endpoints that don't exist in the backend yet:

  • /asteroid/api/users/stats
  • /asteroid/api/users
  • /asteroid/api/users/${id}/role
  • /asteroid/api/users/${id}/deactivate
  • /asteroid/api/users/${id}/activate
  • /asteroid/api/users/create

These endpoints will need to be implemented using define-api when user management features are added.

profile.js

This file contains API calls to user profile endpoints that are currently commented out in the backend:

  • /asteroid/api/user/profile
  • /asteroid/api/user/listening-stats
  • /asteroid/api/user/recent-tracks
  • /asteroid/api/user/top-artists
  • /asteroid/api/user/export-data
  • /asteroid/api/user/clear-history

These will need to be updated once the profile API endpoints are implemented with define-api.

Testing Checklist

  • Update auth-ui.js
  • Update front-page.js
  • Update admin.js
  • Update player.js
  • Test authentication flow
  • Test track loading and playback
  • Test playlist creation
  • Test playlist loading (with new query parameter format)
  • Test adding tracks to playlists
  • Test Icecast status updates
  • Implement and test user management APIs
  • Implement and test user profile APIs

Next Steps

  1. Test the Application: Start the server and test all functionality
  2. Implement Missing APIs: Create user management and profile APIs using define-api
  3. Update Remaining Files: Once APIs are implemented, update users.js and profile.js
  4. Monitor Console: Check browser console for any 404 errors indicating missed endpoints