CtrlK
BlogDocsLog inGet started
Tessl Logo

simon/skills

Auto-generated tile from GitHub (10 skills)

92

1.16x
Quality

94%

Does it follow best practices?

Impact

92%

1.16x

Average score across 44 eval scenarios

SecuritybySnyk

Advisory

Suggest reviewing before use

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-4/

Product Catalog API for an E-Commerce Platform

Problem/Feature Description

A small e-commerce startup needs a product catalog REST API. The frontend team works in TypeScript and wants the API to be type-safe end-to-end. The backend lead has noted that a previous prototype built with Express had two recurring issues: validation errors showed up at runtime with confusing messages because the schema and the TypeScript types drifted apart, and response payloads were leaking internal fields (like cost_price and supplier_id) to the public API.

You have been asked to build the catalog API in Fastify. The API must validate both incoming requests and outgoing responses using a single schema definition that also provides TypeScript types — so there is no possibility of the schema and the types drifting apart. Responses must be serialized using the fastest available method and must automatically strip any internal fields that are not part of the declared response schema.

The product resource has:

  • id (string UUID)
  • name (string, 1–200 chars)
  • description (string, optional)
  • price (number, must be ≥ 0)
  • stock (integer, must be ≥ 0)
  • category (one of: "electronics", "clothing", "food", "books", "other")
  • createdAt (ISO date-time string)

Internal-only fields that must NOT appear in any API response: cost_price, supplier_id, internal_notes.

Output Specification

Produce:

  • package.json
  • src/routes/products.ts — route plugin with at minimum: GET / (list all products), POST / (create a product), GET /:id (get one product)
  • src/schemas/product.ts — TypeBox schema definitions
  • src/app.ts — Fastify application factory that wires up the routes
  • A demo.ts or test.ts script that starts the app, makes a request to POST / with a product that includes the internal fields, and logs whether cost_price and supplier_id appear in the response (they should not)

In-memory storage is fine (a plain array or Map). The goal is the schema and serialization setup, not persistence.

evals

README.md

tile.json