- Home
- Skills
- Blockmatic Icebox
- Basilic Old
- Fastify V5
fastify-v5_skill
- TypeScript
4
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill blockmatic-icebox/basilic-old --skill fastify-v5- SKILL.md6.8 KB
Overview
This skill integrates TypeBox schemas with Fastify to build type-safe REST APIs in TypeScript. It provides patterns for schema-driven route definitions, automatic JSON Schema-based validation, and OpenAPI generation. Use it to enforce request/response contracts and get end-to-end type inference from schemas.
How this skill works
Create TypeBox schemas for params, query, body, and responses and attach them to Fastify route schema objects. Instantiate Fastify with the TypeBox type provider so request types are inferred from schemas and response validation runs automatically. Configure OpenAPI generation via Fastify Swagger plugins using operationId and tags for clean documentation.
When to use it
- Building Fastify v5+ REST APIs with full TypeScript type safety
- Enforcing runtime validation for request params, query, body, and responses
- Generating OpenAPI/Swagger docs directly from route schemas
- Developing reusable plugins or hooks that rely on typed request shapes
- Writing blackbox tests using Fastify inject() with known input/output contracts
Best practices
- Always use fastify.withTypeProvider<TypeBoxTypeProvider>() for routes
- Define response schemas for every expected status code, including errors
- Prefer Type.* constructors (Type.Object, Type.String, etc.) for schemas
- Include operationId and tags in schema for consistent OpenAPI output
- Avoid mixing different schema libraries in the same route to prevent conflicts
Example use cases
- User CRUD API: params, body and 200/404 response schemas for typed handlers
- Auth endpoints: validate request bodies and define standardized error responses
- File streaming or SSE endpoints: declare response type and set proper headers
- Plugin development: build fastify-plugin modules that register typed routes
- Automated API docs: emit OpenAPI spec from TypeBox schemas for client codegen
FAQ
No — when you use TypeBox schemas with TypeBoxTypeProvider, request.params, request.query and request.body are inferred from the schemas; define response schemas to get validation and typing for outputs.
How do I include error formats in OpenAPI?
Define error response schemas for each status code in the route schema and include descriptive examples, operationId, and tags. The swagger plugin will incorporate those into the generated spec.