CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/web-performance

Web performance patterns — lazy loading, bundle optimization, query optimization, compression, and resource management

81

3.23x
Quality

77%

Does it follow best practices?

Impact

97%

3.23x

Average score across 3 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-2/

Order History API

Build a REST API that returns order history for a customer. Each order has line items (products ordered with quantities and prices).

The backend is Node.js with Express and a PostgreSQL database.

Database Schema

CREATE TABLE customers (
  id SERIAL PRIMARY KEY,
  name TEXT NOT NULL,
  email TEXT NOT NULL UNIQUE
);

CREATE TABLE orders (
  id SERIAL PRIMARY KEY,
  customer_id INTEGER REFERENCES customers(id),
  status TEXT NOT NULL DEFAULT 'pending',
  created_at TIMESTAMP DEFAULT NOW()
);

CREATE TABLE order_items (
  id SERIAL PRIMARY KEY,
  order_id INTEGER REFERENCES orders(id),
  product_name TEXT NOT NULL,
  quantity INTEGER NOT NULL,
  unit_price DECIMAL(10,2) NOT NULL
);

Endpoints

  • GET /api/customers/:id/orders — Returns orders for a customer, each order including its line items and the computed total price
  • GET /api/orders/:id — Returns a single order with its line items and computed total

Requirements

  • Orders should be sorted by created_at descending (newest first)
  • Each order in the response includes an items array and a computed total field
  • Proper error handling for invalid/missing customer or order IDs

Output

  • src/index.ts — Express server setup
  • src/db.ts — Database connection setup
  • src/routes/orders.ts — Order route handlers
  • src/types.ts — TypeScript type definitions

Do not include test files or build configuration.

evals

tile.json