Skip to main content
@usenarrator/plugin-fastify The Fastify plugin reads a server as the routes it answers. A route’s JSON Schema or TypeBox schema becomes plain sentences about what the request must look like and what each reply contains, hooks read as when they run, and register calls name the official plugins by what they add.
The plugin declares library: { name: "fastify", versions: ">=4 <6" }. It only narrates files that import or require Fastify or belong to a package that depends on it (see Dependency detection), so an Express app in the same repository is not mistaken for a Fastify server.

Examples

A route with a schema
English
Hooks, decorators and plugins
English

Versions

reply.redirect swapped its arguments in Fastify 5: it is redirect(url, code) where Fastify 4 had redirect(code, url). When the status code is a literal number the plugin can tell which is which. Otherwise it uses the major version your package declares, or the one you pin with version.

What it covers

  • Servers: Fastify() and require("fastify")() with their options, listen, close, ready and inject in tests.
  • Routes: the shorthand methods, route() with several methods, one-line handlers, and returned values as replies.
  • Schemas: JSON Schema and TypeBox for body, querystring, params and headers, and reply shapes per status code.
  • Replies: send, code and status, headers, redirect, and the request’s parts.
  • Hooks (onRequest, preHandler, onClose and the rest), route-level hooks, decorators, error and not-found handlers.
  • Plugins: register with prefixes and options, official @fastify/* plugins by name, autoload, inline plugins and fastify-plugin.

Translating

The English phrasebook is exported as en and typed as FastifyPhrases.