5.0.0 • Published 23 days ago
fastify-204 v5.0.0
fastify-204
Automatically return 204 status code on empty response.
Install
Yarn
yarn add fastify-204
NPM
npm install fastify-204
Usage
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 })
Options
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 ([] ) |
License
Copyright Gilles Marchand, Licensed under MIT.