5.0.0 • Published 23 days ago

fastify-204 v5.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
23 days ago

fastify-204

CI npm JavaScript Style Guide

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

OptionDefaultDescription
onUndefinedtrueReturn 204 when response is undefined
onNullfalseReturn 204 when response is null
onEmptyArrayfalseReturn 204 when response is a empty array ([])

License

Copyright Gilles Marchand, Licensed under MIT.