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
Build the backend API for a simple e-commerce platform using Express and TypeScript.
Resources:
{ id, name, price, stock }{ id, customerEmail, items: [{productId, quantity}], status, total, createdAt }Endpoints:
GET /api/products -- list all productsGET /api/products/:id -- get a single productPOST /api/products -- create a product (name required, price > 0, stock >= 0)POST /api/orders -- place an order:
@GET /api/orders/:id -- get an order by IDSeed the product store with 3-5 sample products. Use in-memory storage.
Produce:
src/server.ts -- server entry pointsrc/app.ts -- Express application setupsrc/routes/products.ts -- product route handlerssrc/routes/orders.ts -- order route handlerspackage.json -- with dependencies listedYou may create additional files as needed.