Why this lesson matters
Understand external apis and use it correctly in an App Router project. Route Handlers expose HTTP contracts from the App Router. External API calls need explicit methods, status codes, validation, timeouts and server-side secret handling.
How to reason about it
- For External APIs, the outcome to verify is: Keep the Route Handler contract explicit in method, status and body.
- In External APIs, keep this failure controlled: Using Route Handlers as thin proxies with no validation or timeout simply moves an unreliable external contract behind your URL.
- External APIs practice target: Create a GET health handler and one external-service adapter that validates the upstream response and maps failures to a stable status.
Practical walkthrough
In the External APIs walkthrough: Keep the Route Handler contract explicit in method, status and body.
app/api/health/route.tstypescript
export async function GET() {
return Response.json({ ok: true }, { status: 200 });
}Practice it yourself
External APIs exercise
Create a GET health handler and one external-service adapter that validates the upstream response and maps failures to a stable status.
- Record the expected result before execution
- Test one valid path and one lesson-specific failure path
- Explain in two lines which boundary owns the decision
