CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/express-error-handling

Production error handling for Express APIs — error middleware, async wrappers,

89

2.02x
Quality

86%

Does it follow best practices?

Impact

97%

2.02x

Average score across 4 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-2/

Build an E-Commerce Orders API

Problem/Feature Description

Build the backend API for a simple e-commerce platform using Express and TypeScript.

Resources:

  • Product: { id, name, price, stock }
  • Order: { id, customerEmail, items: [{productId, quantity}], status, total, createdAt }

Endpoints:

  • GET /api/products -- list all products
  • GET /api/products/:id -- get a single product
  • POST /api/products -- create a product (name required, price > 0, stock >= 0)
  • POST /api/orders -- place an order:
    • customerEmail is required and must contain @
    • items array must be non-empty
    • each item must reference an existing product ID
    • each item quantity must be > 0
    • each referenced product must have sufficient stock
    • deduct stock from products on successful order
    • calculate and store the order total
  • GET /api/orders/:id -- get an order by ID

Seed the product store with 3-5 sample products. Use in-memory storage.

Output Specification

Produce:

  • src/server.ts -- server entry point
  • src/app.ts -- Express application setup
  • src/routes/products.ts -- product route handlers
  • src/routes/orders.ts -- order route handlers
  • package.json -- with dependencies listed

You may create additional files as needed.

evals

tile.json