Automatically return 204 status code on empty response.
yarn add fastify-204
npm install fastify-204
import Fastify from 'fastify'
const fastify = Fastify()
await fastify.register(import('fastify-204'), {
onUndefined: true,
onNull: false,
onEmptyArray: false
})
// This route will reply with a 204 status code
fastify.get('/foo', (req, reply) => {
reply.send()
})
await fastify.listen({ port: 3000 })
Option | Default | Description |
---|---|---|
onUndefined |
true |
Return 204 when response is undefined
|
onNull |
false |
Return 204 when response is null
|
onEmptyArray |
false |
Return 204 when response is a empty array ([] ) |
Copyright Gilles Marchand, Licensed under MIT.