@robcresswell/fastify-reply-ext
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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

Dependents (0)

Package Sidebar

Install

npm i @robcresswell/fastify-reply-ext

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

20.5 kB

Total Files

5

Last publish

Collaborators

  • robcresswell