When using the Fastify framework in TypeScript, ensure that all configuration options are explicitly declared and properly documented. This includes:
Example - Poor Usage:
// Unclear timeout setting with no units
const fastify = Fastify({
http2SessionTimeout: 72000
});
// Incomplete schema definition
fastify.get('/route', {
schema: {
querystring: { name: { type: 'string' } }
}
});
Example - Recommended Usage:
// Clear timeout setting with units
const fastify = Fastify({
http2SessionTimeout: 72000 // Timeout in milliseconds for HTTP/2 sessions
});
// Fully defined schema requirements
fastify.get('/route', {
schema: {
querystring: {
type: 'object',
properties: {
name: { type: 'string' }
},
required: ['name']
}
}
});
By following these guidelines, you can ensure that your Fastify-based applications are properly configured and documented, reducing the risk of user confusion and configuration errors.
Enter the URL of a public GitHub repository