Episode 2 — React Frontend Architecture NextJS / 2.20 — Building APIs with NextJS
2.20.a — Route Handlers & File Conventions
In one sentence: In the App Router, a file named
route.ts(orroute.js) is your HTTP handler for that URL segment — you exportGET,POST, and other verbs instead of registering routes in a central router file.
Navigation: ← 2.20 Overview · Next → HTTP Methods
1. Where “API Routes” Live in Next.js Today
| Router generation | File pattern | Typical path |
|---|---|---|
| Pages Router (still widely deployed) | pages/api/*.ts | /api/users, /api/posts/[id] |
| App Router (current default for new apps) | app/**/route.ts | Same public URLs — different file layout |
This topic focuses on the App Router (app/). In interviews, naming drifts: people say “API routes,” “Route Handlers,” or “edge API.” Clarify which router if the interviewer does not.
2. Minimal Route Handler
// app/api/health/route.ts
import { NextResponse } from 'next/server';
export async function GET() {
return NextResponse.json({ status: 'ok', ts: Date.now() });
}
Public URL: GET /api/health
Rules:
- Only HTTP verbs you export are allowed. If you export only
GET, aPOSTreturns 405 Method Not Allowed (Next.js default behavior for unsupported methods on that segment). - The file must be named
route.ts(orroute.js) — notindex.tsas the handler entry (unlike some meta-frameworks).
3. URL ↔ Folder Mapping
app/
api/
users/
route.ts → /api/users
users/
[id]/
route.ts → /api/users/:id
posts/
route.ts → /api/posts
Dynamic segment: folder [id] becomes a param you read from the context object (covered in the next file with context.params).
Catch-all / optional catch-all: [...slug], [[...slug]] — same idea as dynamic pages; useful for proxy-style APIs.
4. What Runs Inside route.ts?
- Always on the server (never shipped to the browser bundle as client JS).
- Uses the standard Web
RequestandResponseAPIs (with Next.js extensions likeNextRequest). - Can be configured to run on the Edge or Node runtime per route or segment — affects database drivers and Node-only APIs (see 2.20.c).
5. NextResponse vs Response
import { NextResponse } from 'next/server';
return NextResponse.json({ ok: true }, { status: 201, headers: { 'Cache-Control': 'no-store' } });
NextResponse extends Response with helpers (json, redirect, cookies). Plain Response.json() also works in modern runtimes — teams pick one style and stay consistent.
6. Colocation vs pages/api
App Router advantages (often cited in interviews):
- Handlers sit next to the feature (
app/(dashboard)/api/...orapp/api/...) with clearer ownership. - Same project uses RSC + Route Handlers + Server Actions with explicit boundaries.
Pages Router pages/api (legacy mental model):
// pages/api/hello.ts
import type { NextApiRequest, NextApiResponse } from 'next';
export default function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== 'GET') return res.status(405).end();
res.status(200).json({ message: 'hello' });
}
Interview line: “I default to route.ts + Web Request API in App Router; I still recognize NextApiRequest/Response on brownfield Pages apps.”
7. When Route Handlers vs Server Actions
| Need | Prefer |
|---|---|
| Mobile app / third party calls your JSON | Route Handler |
| Webhooks (Stripe, GitHub) | Route Handler |
| Internal form mutation in your Next app only | Often Server Action (2.21) |
Route Handlers are your explicit HTTP surface.
8. Common Mistakes
| Mistake | Symptom |
|---|---|
Wrong filename (handler.ts) | Route never registers |
GET handler tries to read request.json() on GET with no body | Parse errors / confusion |
Expecting req.query from Pages Router | Use request.nextUrl.searchParams instead |
9. Thirty-Second Interview Answer
“In the App Router I add route.ts under app/api/.... I export GET, POST, and so on. Each function receives a Web Request and returns a Response or NextResponse. Dynamic path bits come from params. Unsupported methods automatically get 405 if I did not export that verb.”
Next: 2.20.b — HTTP Methods (GET → DELETE)
Part 2 — Deep Encyclopedia (Route handlers & conventions)
How to use this section: Read sequentially or jump by drill number. Each block has a scenario, a prompt (what an interviewer might ask), a model answer, and often a code sketch.
E001 — API drill 1: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 1: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #1.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #1, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E002 — API drill 2: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 2: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #2.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #2, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E003 — API drill 3: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 3: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #3.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #3, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E004 — API drill 4: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 4: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #4.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #4, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E005 — API drill 5: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 5: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #5.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #5, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E006 — API drill 6: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 6: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #6.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #6, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E007 — API drill 7: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 7: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #7.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #7, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E008 — API drill 8: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 8: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #8.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #8, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E009 — API drill 9: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 9: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #9.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #9, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E010 — API drill 10: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 10: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #10.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #10, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E011 — API drill 11: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 11: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #11.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #11, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E012 — API drill 12: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 12: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #12.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #12, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E013 — API drill 13: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 13: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #13.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #13, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E014 — API drill 14: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 14: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #14.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #14, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E015 — API drill 15: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 15: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #15.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #15, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E016 — API drill 16: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 16: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #16.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #16, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E017 — API drill 17: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 17: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #17.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #17, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E018 — API drill 18: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 18: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #18.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #18, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E019 — API drill 19: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 19: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #19.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #19, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E020 — API drill 20: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 20: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #20.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #20, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E021 — API drill 21: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 21: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #21.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #21, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E022 — API drill 22: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 22: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #22.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #22, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E023 — API drill 23: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 23: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #23.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #23, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E024 — API drill 24: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 24: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #24.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #24, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E025 — API drill 25: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 25: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #25.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #25, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E026 — API drill 26: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 26: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #26.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #26, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E027 — API drill 27: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 27: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #27.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #27, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E028 — API drill 28: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 28: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #28.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #28, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E029 — API drill 29: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 29: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #29.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #29, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E030 — API drill 30: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 30: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #30.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #30, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E031 — API drill 31: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 31: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #31.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #31, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E032 — API drill 32: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 32: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #32.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #32, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E033 — API drill 33: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 33: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #33.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #33, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E034 — API drill 34: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 34: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #34.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #34, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E035 — API drill 35: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 35: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #35.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #35, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E036 — API drill 36: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 36: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #36.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #36, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E037 — API drill 37: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 37: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #37.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #37, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E038 — API drill 38: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 38: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #38.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #38, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E039 — API drill 39: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 39: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #39.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #39, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E040 — API drill 40: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 40: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #40.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #40, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E041 — API drill 41: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 41: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #41.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #41, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E042 — API drill 42: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 42: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #42.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #42, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E043 — API drill 43: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 43: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #43.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #43, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E044 — API drill 44: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 44: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #44.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #44, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E045 — API drill 45: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 45: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #45.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #45, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E046 — API drill 46: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 46: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #46.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #46, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E047 — API drill 47: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 47: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #47.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #47, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E048 — API drill 48: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 48: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #48.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #48, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E049 — API drill 49: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 49: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #49.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #49, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E050 — API drill 50: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 50: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #50.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #50, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E051 — API drill 51: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 51: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #51.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #51, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E052 — API drill 52: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 52: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #52.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #52, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E053 — API drill 53: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 53: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #53.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #53, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E054 — API drill 54: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 54: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #54.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #54, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E055 — API drill 55: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 55: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #55.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #55, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E056 — API drill 56: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 56: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #56.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #56, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E057 — API drill 57: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 57: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #57.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #57, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E058 — API drill 58: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 58: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #58.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #58, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E059 — API drill 59: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 59: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #59.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #59, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E060 — API drill 60: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 60: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #60.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #60, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E061 — API drill 61: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 61: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #61.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #61, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E062 — API drill 62: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 62: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #62.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #62, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E063 — API drill 63: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 63: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #63.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #63, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E064 — API drill 64: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 64: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #64.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #64, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E065 — API drill 65: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 65: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #65.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #65, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E066 — API drill 66: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 66: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #66.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #66, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E067 — API drill 67: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 67: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #67.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #67, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E068 — API drill 68: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 68: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #68.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #68, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E069 — API drill 69: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 69: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #69.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #69, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E070 — API drill 70: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 70: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #70.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #70, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E071 — API drill 71: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 71: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #71.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #71, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E072 — API drill 72: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 72: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #72.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #72, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E073 — API drill 73: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 73: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #73.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #73, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E074 — API drill 74: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 74: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #74.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #74, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E075 — API drill 75: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 75: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #75.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #75, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E076 — API drill 76: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 76: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #76.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #76, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E077 — API drill 77: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 77: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #77.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #77, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E078 — API drill 78: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 78: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #78.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #78, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E079 — API drill 79: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 79: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #79.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #79, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E080 — API drill 80: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 80: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #80.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #80, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E081 — API drill 81: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 81: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #81.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #81, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E082 — API drill 82: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 82: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #82.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #82, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E083 — API drill 83: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 83: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #83.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #83, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E084 — API drill 84: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 84: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #84.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #84, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E085 — API drill 85: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 85: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #85.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #85, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E086 — API drill 86: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 86: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #86.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #86, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E087 — API drill 87: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 87: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #87.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #87, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E088 — API drill 88: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 88: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #88.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #88, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E089 — API drill 89: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 89: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #89.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #89, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E090 — API drill 90: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 90: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #90.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #90, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E091 — API drill 91: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 91: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #91.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #91, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E092 — API drill 92: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 92: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #92.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #92, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E093 — API drill 93: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 93: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #93.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #93, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E094 — API drill 94: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 94: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #94.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #94, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E095 — API drill 95: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 95: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #95.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #95, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E096 — API drill 96: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 96: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #96.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #96, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E097 — API drill 97: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 97: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #97.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #97, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E098 — API drill 98: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 98: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #98.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #98, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E099 — API drill 99: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 99: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #99.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #99, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E100 — API drill 100: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 100: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #100.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #100, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E101 — API drill 101: Idempotency-Key header for POST /api/payments.
Scenario: Idempotency-Key header for POST /api/payments. (variation 101: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #101.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #101, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E102 — API drill 102: Content-Type negotiation JSON vs msgpack.
Scenario: Content-Type negotiation JSON vs msgpack. (variation 102: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #102.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #102, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E103 — API drill 103: Binary upload > 4.5MB on serverless
Scenario: Binary upload > 4.5MB on serverless — streaming workaround. (variation 103: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #103.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #103, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E104 — API drill 104: HMAC webhook verification constant-time compare.
Scenario: HMAC webhook verification constant-time compare. (variation 104: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #104.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #104, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E105 — API drill 105: Rate limit by API key in Redis sliding window.
Scenario: Rate limit by API key in Redis sliding window. (variation 105: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #105.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #105, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E106 — API drill 106: OpenAPI generation from Zod schemas.
Scenario: OpenAPI generation from Zod schemas. (variation 106: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #106.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #106, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E107 — API drill 107: Versioned URL /api/v2 with sunset headers.
Scenario: Versioned URL /api/v2 with sunset headers. (variation 107: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #107.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #107, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E108 — API drill 108: HEAD request to check existence without body cost.
Scenario: HEAD request to check existence without body cost. (variation 108: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #108.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #108, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E109 — API drill 109: Conditional GET with ETag round trip.
Scenario: Conditional GET with ETag round trip. (variation 109: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #109.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #109, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}
E110 — API drill 110: CORS credentialed requests with wildcard mistake.
Scenario: CORS credentialed requests with wildcard mistake. (variation 110: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #110.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #110, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const idem = req.headers.get('idempotency-key');
// store idem -> response mapping in Redis with TTL
return NextResponse.json({ ok: true });
}