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

Blog API

Build a Fastify API for a blogging platform. The API manages blog posts and comments.

A blog post has: id (string), title (string, 1-200 chars), content (string), authorId (string), tags (array of strings), published (boolean), and createdAt/updatedAt (ISO date strings).

A comment has: id (string), postId (string), authorName (string), content (string, 1-1000 chars), and createdAt.

Endpoints

  • POST /api/posts -- Create a blog post.
  • GET /api/posts -- List posts. Accepts optional query params: published (boolean), tag (string), page (integer), limit (integer, max 50).
  • GET /api/posts/:id -- Get a single post with its comments.
  • PUT /api/posts/:id -- Update a post.
  • DELETE /api/posts/:id -- Delete a post and its comments.
  • POST /api/posts/:postId/comments -- Add a comment to a post.
  • GET /api/posts/:postId/comments -- List comments for a post.

Use in-memory arrays for storage.

Output

Produce TypeScript files in a src/ directory:

  • src/app.ts -- Fastify app setup with TypeScript type provider
  • src/plugins/posts.ts -- Post routes
  • src/plugins/comments.ts -- Comment routes
  • src/services/postService.ts -- Post business logic
  • src/services/commentService.ts -- Comment business logic
  • src/schemas/post.ts -- Shared post schemas
  • src/schemas/comment.ts -- Shared comment schemas
  • src/server.ts -- Server startup

Do not include test files or build configuration.

evals

tile.json