CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/fastify-best-practices

Fastify patterns — always apply schema-first validation, plugin encapsulation, structured error handling, hooks lifecycle, decorators, TypeScript type providers, production hardening (CORS, helmet, rate limiting), pino logging, graceful shutdown, and correct async handler patterns

89

2.75x
Quality

89%

Does it follow best practices?

Impact

91%

2.75x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-5/

Restaurant Order API

Build a Fastify API for a restaurant ordering system. The API should handle creating, listing, and retrieving orders.

An order has: id (UUID string), customerName (string), items (array of order items), status (string: "pending", "preparing", "ready", "delivered"), totalPrice (number), and createdAt (ISO date string). Each order item has: menuItemId (integer), name (string), size ("small", "medium", "large"), quantity (integer, 1-20), and price (number).

Endpoints

  • POST /api/orders -- Create a new order. Accepts customerName and items in the body.
  • GET /api/orders -- List all orders. Accepts optional status query parameter to filter.
  • GET /api/orders/:id -- Get a single order by ID.
  • PATCH /api/orders/:id/status -- Update order status. Accepts status in the body.

Use an in-memory array for storage (no database needed).

Output

Produce TypeScript files in a src/ directory:

  • src/app.ts -- Fastify app setup and configuration
  • src/plugins/orders.ts -- Order routes and handlers
  • src/services/orderService.ts -- Business logic for order management
  • src/server.ts -- Server startup

Do not include test files or build configuration.

evals

tile.json