Enforce strict three-layer architecture: thin HTTP routes, pure service logic with domain errors, isolated data access with dependency injection.
94
93%
Does it follow best practices?
Impact
97%
1.08xAverage score across 5 eval scenarios
Passed
No known issues
A small e-commerce startup is building an order management backend using Node.js and TypeScript. The existing prototype works for the happy path, but the team is getting complaints that error responses are inconsistent — sometimes returning stack traces, sometimes returning 500 for every error regardless of the cause, and sometimes returning messages like "404: order not found" directly from deep inside the business logic.
The team lead wants a clean implementation of the order creation endpoint with proper error handling. The endpoint should accept a new order, apply business rules, and return meaningful error responses to the client. The core concern is that the error handling needs to be structured so that it can be reused if the same logic is later called from a background job or a CLI migration tool.
Implement the order creation feature as TypeScript files. Produce:
src/errors/domain.ts — Error type definitionssrc/routes/orders.ts — The HTTP route handler for POST /api/orderssrc/services/orderService.ts — The business logic for creating an ordersrc/repositories/orderRepo.ts — Data access for orders (can use a simple in-memory store or stub out a db query interface)plan.md — A brief description of how errors flow through the layers in your implementationThe implementation does not need to connect to a real database. Use stub/mock data access that mimics real behavior.
Business rules for order creation:
customerName is requireditems must be a non-empty arrayproductId and quantity > 0evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
skills
separation-of-concerns
verifiers