@robcresswell/fastify-reply-ext

A really basic plugin for Fastify that adds reply helpers for all the status codes. This has a few uses;

Usage no npm install needed!

<script type="module">
  import robcresswellFastifyReplyExt from 'https://cdn.skypack.dev/@robcresswell/fastify-reply-ext';
</script>

README

fastify-reply-ext

A really basic plugin for Fastify that adds reply helpers for all the status codes. This has a few uses;

  • Remembering / autocompleting names of the HTTP responses is easier than remembering the numbers
  • Make your error responses consistently shaped

For example,

reply.badRequest();

is the same as

reply.code(400).send({ statusCode: 400, message: 'Bad Request' });

Getting started

import { fastify } from 'Fastify';
import { replyExtPlugin } from '@robcresswell/fastify-reply-ext';

const server = fastify();
await server.register(replyExtPlugin);

See Fastify's plugin docs for more information