Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Custom error handling in Fastify.
const fastify = require('fastify')({ logger: true })
fastify.get('/error', async (request, reply) => {
throw new Error('Something went wrong')
})
fastify.setErrorHandler(async (error, request, reply) => {
console.error(error.message)
reply.status(500).send('Server Error')
})
fastify.listen({ port: 3000 }, (err, address) => {
if (err) throw err
console.log(`Server running at ${address}`)
})Fastify is a high-performance, low-overhead web framework for Node.js. It emphasizes speed, schema-based validation, and a developer-friendly plugin system for building APIs and backend services.
Origin & Creator
Fastify was created by Matteo Collina and Tomas Della Vedova in 2017 as a modern, high-performance alternative to Express.js.
Industrial Note
Fastify is preferred for high-performance APIs, microservices, and backend systems where speed, schema validation, and low overhead are critical.