Next.js App Router API patterns — Route Handlers, Server Actions, middleware, validation, caching, error handling
92
90%
Does it follow best practices?
Impact
95%
1.58xAverage score across 5 eval scenarios
Passed
No known issues
A restaurant needs a Next.js App Router application to manage its menu. Build the API endpoints and a simple page to display the menu.
Endpoints:
GET /api/menu -- list all menu itemsGET /api/menu/[id] -- get a single menu item by IDPOST /api/menu -- create a new menu item (fields: name, description, price, category)PUT /api/menu/[id] -- update a menu itemDELETE /api/menu/[id] -- delete a menu itemBusiness rules:
Use in-memory storage (no real database needed).
Also create a page at /menu that displays all menu items fetched from the API.
Produce:
app/api/menu/route.ts -- GET and POST handlersapp/api/menu/[id]/route.ts -- GET, PUT, DELETE handlers for single itemsapp/menu/page.tsx -- server component page displaying menu itemspackage.json -- with dependenciesYou may create additional files as needed for a well-structured codebase.