Open
Description
Issue ID: 005
Priority: High
Status: Open
Created: 2025-01-05
Component: API/Admin
Description
The /api/admin/refresh
endpoint is currently non-functional. When called, it only returns a success message with a TODO comment stating "This would trigger a full data refresh" but doesn't actually perform any data refresh operations.
Current Behavior
When making a POST request to /api/admin/refresh
:
- Returns:
{ "message": "Refresh triggered", "todo": "This would trigger a full data refresh" }
- No actual data refresh occurs
- No wallet balances are updated
- No token prices are refreshed
Expected Behavior
The endpoint should:
- Trigger the prefetch process programmatically
- Perform the same operations as running
bun run prefetch:force
- Update all wallet balances from the blockchain
- Refresh token prices and metadata
- Return meaningful status information about the refresh operation
Technical Details
Current Implementation
Located in src/routes/api.ts
, the endpoint handler is:
app.post('/api/admin/refresh', async (c) => {
// TODO: Implement actual refresh logic
return c.json({
message: 'Refresh triggered',
todo: 'This would trigger a full data refresh'
});
});
Required Implementation
The endpoint should:
- Import and utilize the prefetch functionality from
src/scripts/prefetch.ts
- Handle the refresh operation asynchronously
- Provide progress tracking or status updates
- Handle errors gracefully
- Ensure proper rate limiting is maintained
Impact
- Users: Cannot trigger data refreshes through the API
- System: Must rely on manual CLI commands or scheduled tasks for data updates
- Operations: Limits automation capabilities and real-time data management
Proposed Solution
- Import the prefetch logic into the API route handler
- Implement proper async handling for the long-running operation
- Consider implementing a job queue or background task system
- Return a job ID that can be used to check refresh status
- Add a companion endpoint to check refresh job status
Related Files
src/routes/api.ts
- Contains the non-functional endpointsrc/scripts/prefetch.ts
- Contains the working prefetch logicsrc/services/database.ts
- Database operationssrc/services/solana.ts
- Blockchain data fetching
Notes
This is a critical feature for maintaining data freshness without manual intervention. The endpoint exists but lacks implementation, which could mislead users expecting it to work.