Skip to content

Automatically return 204 status on empty response.

License

Notifications You must be signed in to change notification settings

Shiva127/fastify-204

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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.

About

Automatically return 204 status on empty response.

Resources

License

Stars

Watchers

Forks