Overview
Implement a `GET` handler that returns the current USDC to NGN exchange rate by calling the existing exchange rate utility in the codebase.
⚠️ Scope: Write your code only inside `app/api/routes-d/exchange-rate/route.ts`. Do not wire this into any page, component, or existing route.
Create the route file
File: `app/api/routes-d/exchange-rate/route.ts`
Note: The existing `app/api/exchange-rate/` route handles this for the main app. Do NOT modify that file. Write a fresh, standalone handler in the `routes-d` folder only.
Handler logic
- No auth required — exchange rate is public data
- Check the existing `app/api/exchange-rate/route.ts` to understand how the rate is fetched in this codebase, then replicate the same approach in your file
- Return the rate along with a timestamp
Expected response
```json
{
"rate": {
"from": "USDC",
"to": "NGN",
"value": 1620.50,
"fetchedAt": "2025-01-01T12:00:00.000Z"
}
}
```
Error handling
If the upstream rate fetch fails, return:
```json
{ "error": "Unable to fetch exchange rate" }
```
Status: `503 Service Unavailable`
Acceptance criteria
Overview
Implement a `GET` handler that returns the current USDC to NGN exchange rate by calling the existing exchange rate utility in the codebase.
Create the route file
File: `app/api/routes-d/exchange-rate/route.ts`
Handler logic
Expected response
```json
{
"rate": {
"from": "USDC",
"to": "NGN",
"value": 1620.50,
"fetchedAt": "2025-01-01T12:00:00.000Z"
}
}
```
Error handling
If the upstream rate fetch fails, return:
```json
{ "error": "Unable to fetch exchange rate" }
```
Status: `503 Service Unavailable`
Acceptance criteria