Production error handling for Express APIs — error middleware, async wrappers,
89
86%
Does it follow best practices?
Impact
97%
2.02xAverage score across 4 eval scenarios
Passed
No known issues
A small online bookstore needs a REST API to manage its inventory. Build it using Express and TypeScript.
Endpoints:
GET /api/books -- list all booksGET /api/books/:id -- get a single book by IDPOST /api/books -- create a new book (fields: title, author, isbn, price)PUT /api/books/:id -- update a bookDELETE /api/books/:id -- delete a bookBusiness rules:
Use in-memory storage (no real database needed).
Produce:
src/server.ts -- server entry pointsrc/app.ts -- Express application setupsrc/routes/books.ts -- route handlers for book CRUDpackage.json -- with dependencies listed (no need to run npm install)You may create additional files as needed for a well-structured codebase.