Production Hono patterns — zValidator hooks, typed generics, error handling, middleware composition, testing, and multi-runtime deployment
87
80%
Does it follow best practices?
Impact
98%
2.57xAverage score across 5 eval scenarios
Passed
No known issues
A warehouse needs an API to track product inventory. Build it using Hono and TypeScript, targeting Bun. The API should support CRUD operations on products and inventory adjustment transactions.
Endpoints:
POST /api/products -- create a product (fields: sku, name, category, initialStock)GET /api/products -- list all products with current stock levelsGET /api/products/:id -- get a single productPATCH /api/products/:id -- update product name or categoryPOST /api/products/:id/adjust -- adjust stock (fields: quantity which can be positive or negative, reason)GET /api/products/:id/history -- get adjustment history for a productBusiness rules:
Use in-memory storage.
Produce:
src/app.ts -- Hono applicationsrc/index.ts -- Bun entry pointsrc/routes/products.ts -- product endpointssrc/routes/adjustments.ts -- stock adjustment endpointssrc/schemas.ts -- Zod validation schemaspackage.json -- with dependencies (no need to install)You may create additional files as needed.