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-3/

File Metadata Service

Build a Fastify API that manages file upload metadata. The service tracks files uploaded by users -- it does not handle the actual binary upload, just the metadata records.

A file record has: id (UUID string), filename (string), mimeType (string), sizeBytes (integer), uploadedBy (string -- user ID), status ("pending", "processing", "ready", "failed"), and createdAt (ISO date string).

Endpoints

  • POST /api/files -- Register a new file upload. Accepts filename, mimeType, sizeBytes, and uploadedBy.
  • GET /api/files -- List files. Accepts optional query params: uploadedBy (string), status (string), mimeType (string).
  • GET /api/files/:id -- Get file details.
  • PATCH /api/files/:id/status -- Update file processing status. Accepts status in the body.
  • DELETE /api/files/:id -- Delete a file record.
  • POST /api/files/webhook -- Receive processing completion webhooks from an external file processor. Accepts fileId, status ("ready" or "failed"), and optional error (string).

Use an in-memory store.

Output

Produce TypeScript files in a src/ directory:

  • src/app.ts -- Fastify app setup
  • src/plugins/files.ts -- File management routes
  • src/plugins/webhook.ts -- Webhook receiver routes
  • src/services/fileService.ts -- File business logic
  • src/server.ts -- Server startup

Do not include test files or build configuration.

evals

tile.json