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

Notification Microservice

Build a Fastify microservice that manages user notifications. The service will be deployed in a Docker container behind an API gateway.

Endpoints

  • POST /api/notifications -- Create a notification. Accepts userId (string), type ("email", "sms", "push"), title (string), message (string), and optional metadata (object).
  • GET /api/notifications/:userId -- List notifications for a user. Accepts optional query params read (boolean) and limit (integer, default 20).
  • PATCH /api/notifications/:id/read -- Mark a notification as read.
  • DELETE /api/notifications/:id -- Delete a notification.
  • GET /api/health -- Health check endpoint returning { status: "ok" }.

Use an in-memory store. Each notification gets an id, createdAt timestamp, and read: false by default.

Output

Produce TypeScript files in a src/ directory:

  • src/app.ts -- Fastify app setup and plugin registration
  • src/plugins/notifications.ts -- Notification routes
  • src/plugins/health.ts -- Health check route
  • src/services/notificationService.ts -- Notification business logic
  • src/server.ts -- Server startup and configuration

Do not include test files or build configuration.

evals

tile.json