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
89%
Does it follow best practices?
Impact
91%
2.75xAverage score across 5 eval scenarios
Passed
No known issues
Build a Fastify API that acts as an authentication gateway. The service manages user sessions using JWT tokens.
POST /api/auth/register -- Register a new user. Accepts email, password, and displayName. Stores the user in memory (hash the password with bcrypt or similar).POST /api/auth/login -- Authenticate a user. Accepts email and password. Returns a JWT access token.GET /api/auth/me -- Get the current user's profile. Requires a valid JWT in the Authorization header (Bearer token).POST /api/auth/logout -- Invalidate the current session (add token to a blocklist).The JWT secret should come from an environment variable JWT_SECRET. Tokens should expire in 1 hour.
Protected routes (/me, /logout) should return 401 if no valid token is provided.
Produce TypeScript files in a src/ directory:
src/app.ts -- Fastify app setupsrc/plugins/auth.ts -- Authentication plugin with hooks and helperssrc/plugins/users.ts -- User management routessrc/services/userService.ts -- User storage and password hashingsrc/services/tokenService.ts -- JWT creation and verificationsrc/server.ts -- Server startupDo not include test files or build configuration.
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
skills
fastify-best-practices
verifiers