• Stars
    star
    643
  • Rank 67,408 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Swagger documentation generator for Fastify

@fastify/swagger

NPM version CI workflow js-standard-style

A Fastify plugin for serving Swagger (OpenAPI v2) or OpenAPI v3 schemas, which are automatically generated from your route schemas, or from an existing Swagger/OpenAPI schema.

Supports Fastify versions 4.x.

  • Please refer to 6.x for Fastify ^3.x compatibility.
  • Please refer to 3.x for Fastify ^2.x compatibility.
  • Please refer to 1.x for Fastify ^1.x compatibility.

If you are looking for a plugin to generate routes from an existing OpenAPI schema, check out fastify-openapi-glue.

Following plugins serve swagger/openapi front-ends based on the swagger definitions generated by this plugin:

See also the migration guide for migrating from @fastify/swagger version <= <=7.x to version >=8.x.

Install

npm i @fastify/swagger

Usage

Add it to your project with register, pass it some options, call the swagger API, and you are done!

const fastify = require('fastify')()

await fastify.register(require('@fastify/swagger'), {
  swagger: {
    info: {
      title: 'Test swagger',
      description: 'Testing the Fastify swagger API',
      version: '0.1.0'
    },
    externalDocs: {
      url: 'https://swagger.io',
      description: 'Find more info here'
    },
    host: 'localhost',
    schemes: ['http'],
    consumes: ['application/json'],
    produces: ['application/json'],
    tags: [
      { name: 'user', description: 'User related end-points' },
      { name: 'code', description: 'Code related end-points' }
    ],
    definitions: {
      User: {
        type: 'object',
        required: ['id', 'email'],
        properties: {
          id: { type: 'string', format: 'uuid' },
          firstName: { type: 'string' },
          lastName: { type: 'string' },
          email: {type: 'string', format: 'email' }
        }
      }
    },
    securityDefinitions: {
      apiKey: {
        type: 'apiKey',
        name: 'apiKey',
        in: 'header'
      }
    }
  }
})

fastify.put('/some-route/:id', {
  schema: {
    description: 'post some data',
    tags: ['user', 'code'],
    summary: 'qwerty',
    params: {
      type: 'object',
      properties: {
        id: {
          type: 'string',
          description: 'user id'
        }
      }
    },
    body: {
      type: 'object',
      properties: {
        hello: { type: 'string' },
        obj: {
          type: 'object',
          properties: {
            some: { type: 'string' }
          }
        }
      }
    },
    response: {
      201: {
        description: 'Successful response',
        type: 'object',
        properties: {
          hello: { type: 'string' }
        }
      },
      default: {
        description: 'Default response',
        type: 'object',
        properties: {
          foo: { type: 'string' }
        }
      }
    },
    security: [
      {
        "apiKey": []
      }
    ]
  }
}, (req, reply) => {})

await fastify.ready()
fastify.swagger()

API

Register options

Modes

@fastify/swagger supports two registration modes dynamic and static:

Dynamic

dynamic is the default mode, if you use @fastify/swagger this way API schemas will be auto-generated from route schemas:

// All of the below parameters are optional but are included for demonstration purposes
{
  // swagger 2.0 options
  swagger: {
    info: {
      title: String,
      description: String,
      version: String
    },
    externalDocs: Object,
    host: String,
    schemes: [ String ],
    consumes: [ String ],
    produces: [ String ],
    tags: [ Object ],
    securityDefinitions: Object
  },
  // openapi 3.0.3 options
  // openapi: {
  //   info: {
  //     title: String,
  //     description: String,
  //     version: String,
  //   },
  //   externalDocs: Object,
  //   servers: [ Object ],
  //   components: Object,
  //   security: [ Object ],
  //   tags: [ Object ]
  // }
}

All properties detailed in the Swagger (OpenAPI v2) and OpenAPI v3 specifications can be used. @fastify/swagger will generate API schemas that adhere to the Swagger specification by default. If provided an openapi option it will generate OpenAPI compliant API schemas instead.

Examples of using @fastify/swagger in dynamic mode:

Static

static mode must be configured explicitly. In this mode @fastify/swagger serves an already existing Swagger or OpenAPI schema that is passed to it in specification.path:

{
  mode: 'static',
  specification: {
    path: './examples/example-static-specification.yaml',
    postProcessor: function(swaggerObject) {
      return swaggerObject
    },
    baseDir: '/path/to/external/spec/files/location',
  },
}

The specification.postProcessor parameter is optional. It allows you to change your Swagger object on the fly (for example - based on the environment). It accepts swaggerObject - a JavaScript object that was parsed from your yaml or json file and should return a Swagger schema object.

specification.baseDir allows specifying the directory where all spec files that are included in the main one using $ref will be located. By default, this is the directory where the main spec file is located. Provided value should be an absolute path without trailing slash.

An example of using @fastify/swagger with static mode enabled can be found here.

Options

Option Default Description
hiddenTag X-HIDDEN Tag to control hiding of routes.
hideUntagged false If true remove routes without tags from resulting Swagger/OpenAPI schema file.
initOAuth {} Configuration options for Swagger UI initOAuth.
openapi {} OpenAPI configuration.
stripBasePath true Strips base path from routes in docs.
swagger {} Swagger configuration.
transform null Transform method for the route's schema and url. documentation.
refResolver {} Option to manage the $refs of your application's schemas. Read the $ref documentation
exposeHeadRoutes false Include HEAD routes in the definitions

Transform

By passing a synchronous transform function you can modify the route's url and schema.

Some possible uses of this are:

  • add the hide flag on schema according to your own logic based on url & schema
  • altering the route url into something that's more suitable for the api spec
  • using different schemas such as Joi and transforming them to standard JSON schemas expected by this plugin

This option is available in dynamic mode only.

Examples of all the possible uses mentioned:

const convert = require('joi-to-json')

await fastify.register(require('@fastify/swagger'), {
  swagger: { ... },
  transform: ({ schema, url }) => {
    const {
      params,
      body,
      querystring,
      headers,
      response,
      ...transformedSchema
    } = schema
    let transformedUrl = url

    // Transform the schema as you wish with your own custom logic.
    // In this example convert is from 'joi-to-json' lib and converts a Joi based schema to json schema
    if (params) transformedSchema.params = convert(params)
    if (body) transformedSchema.body = convert(body)
    if (querystring) transformedSchema.querystring = convert(querystring)
    if (headers) transformedSchema.headers = convert(headers)
    if (response) transformedSchema.response = convert(response)

    // can add the hide tag if needed
    if (url.startsWith('/internal')) transformedSchema.hide = true

    // can transform the url
    if (url.startsWith('/latest_version/endpoint')) transformedUrl = url.replace('latest_version', 'v3')

    return { schema: transformedSchema, url: transformedUrl }
  }
})

Managing your $refs

When this plugin is configured as dynamic mode, it will resolve all $refs in your application's schemas. This process will create an new in-line schema that is going to reference itself.

This logic step is done to make sure that the generated documentation is valid, otherwise the Swagger UI will try to fetch the schemas from the server or the network and fail.

By default, this option will resolve all $refs renaming them to def-${counter}, but your view models keep the original $id naming thanks to the title parameter.

To customize this logic you can pass a refResolver option to the plugin:

await fastify.register(require('@fastify/swagger'), {
  swagger: { ... },
  ...
  refResolver: {
    buildLocalReference (json, baseUri, fragment, i) {
      return json.$id || `my-fragment-${i}`
    }
  }
}

To deep down the buildLocalReference arguments, you may read the documentation.

Route options

It is possible to instruct @fastify/swagger to include specific HEAD routes in the definitions by adding exposeHeadRoute in the route config, like so:

  fastify.get('/with-head', {
    schema: {
      operationId: 'with-head',
      response: {
        200: {
          description: 'Expected Response',
          type: 'object',
          properties: {
            foo: { type: 'string' }
          }
        }
      }
    },
    config: {
      swagger: {
        exposeHeadRoute: true,
      }
    }
  }, () => {})

Response Options

Response description and response body description

description is a required field as per the Swagger specification. If it is not provided then the plugin will automatically generate one with the value 'Default Response'. If you supply a description it will be used for both the response and response body schema, for example:

fastify.get('/description', {
  schema: {
    response: {
      200: {
        description: 'response and schema description',
        type: 'string'
      }
    }
  }
}, () => {})

Generates this in a Swagger (OpenAPI v2) schema's paths:

{
  "/description": {
    "get": {
      "responses": {
        "200": {
          "description": "response and schema description",
          "schema": {
            "description": "response and schema description",
            "type": "string"
          }
        }
      }
    }
  }
}

And this in a OpenAPI v3 schema's paths:

{
  "/description": {
    "get": {
      "responses": {
        "200": {
          "description": "response and schema description",
          "content": {
            "application/json": {
              "schema": {
                "description": "response and schema description",
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}

If you want to provide different descriptions for the response and response body, use the x-response-description field alongside description:

fastify.get('/responseDescription', {
  schema: {
    response: {
      200: {
        'x-response-description': 'response description',
        description: 'schema description',
        type: 'string'
      }
    }
  }
}, () => {})

Status code 2xx

Fastify supports both the 2xx and 3xx status codes, however Swagger (OpenAPI v2) itself does not. @fastify/swagger transforms 2xx status codes into 200, but will omit it if a 200 status code has already been declared. OpenAPI v3 supports the 2xx syntax so is unaffected.

Example:

{
  response: {
    '2xx': {
      description: '2xx',
      type: 'object'
    }
  }
}

// will become
{
  response: {
    200: {
      schema: {
        description: '2xx',
        type: 'object'
      }
    }
  }
}

Response headers

You can decorate your own response headers by following the below example:

{
  response: {
    200: {
      type: 'object',
      headers: {
        'X-Foo': {
          type: 'string'
        }
      }
    }
  }
}

Note: You need to specify type property when you decorate the response headers, otherwise the schema will be modified by Fastify.

Different content types responses

Note: not supported by Swagger (OpenAPI v2), only OpenAPI v3 Different content types responses are supported by @fastify/swagger and @fastify. Please use content for the response otherwise Fastify itself will fail to compile the schema:

{
  response: {
    200: {
      description: 'Description and all status-code based properties are working',
      content: {
        'application/json': {
          schema: { 
            name: { type: 'string' }, 
            image: { type: 'string' }, 
            address: { type: 'string' } 
          }
        }, 
        'application/vnd.v1+json': {
          schema: { 
            fullName: { type: 'string' }, 
            phone: { type: 'string' } 
          }
        }
      }
    }
  }
}
Empty Body Responses

Empty body responses are supported by @fastify/swagger. Please specify type: 'null' for the response otherwise Fastify itself will fail to compile the schema:

{
  response: {
    204: {
      type: 'null',
      description: 'No Content'
    },
    503: {
      type: 'null',
      description: 'Service Unavailable'
    }
  }
}

OpenAPI Parameter Options

Note: OpenAPI's terminology differs from Fastify's. OpenAPI uses "parameter" to refer to parts of a request that in Fastify's validation documentation are called "querystring", "params", and "headers".

OpenAPI provides some options beyond those provided by the JSON schema specification for specifying the shape of parameters. A prime example of this is the collectionFormat option for specifying how to encode parameters that should be handled as arrays of values.

These encoding options only change how Swagger UI presents its documentation and how it generates curl commands when the Try it out button is clicked. Depending on which options you set in your schema, you may also need to change the default query string parser used by Fastify so that it produces a JavaScript object that will conform to the schema. As far as arrays are concerned, the default query string parser conforms to the collectionFormat: "multi" specification. If you were to select collectionFormat: "csv", you would have to replace the default query string parser with one that parses CSV parameter values into arrays. The same applies to the other parts of a request that OpenAPI calls "parameters" and which are not encoded as JSON in a request.

You can also apply different serialization style and explode as specified here.

@fastify/swagger supports these options as shown in this example:

// Need to add a collectionFormat keyword to ajv in fastify instance
const fastify = Fastify({
  ajv: {
    customOptions: {
      keywords: ['collectionFormat']
    }
  }
})

fastify.route({
  method: 'GET',
  url: '/',
  schema: {
    querystring: {
      type: 'object',
      required: ['fields'],
      additionalProperties: false,
      properties: {
        fields: {
          type: 'array',
          items: {
            type: 'string'
          },
          minItems: 1,
          //
          // Note that this is an OpenAPI version 2 configuration option. The
          // options changed in version 3.
          //
          // Put `collectionFormat` on the same property which you are defining
          // as an array of values. (i.e. `collectionFormat` should be a sibling
          // of the `type: "array"` specification.)
          collectionFormat: 'multi'
        }
      },
     // OpenAPI 3 serialization options
     explode: false,
     style: "deepObject"
    }
  },
  handler (request, reply) {
    reply.send(request.query.fields)
  }
})

There is a complete runnable example here.

Complex serialization in query and cookie, eg. JSON

Note: not supported by Swagger (OpenAPI v2), only OpenAPI v3

http://localhost/?filter={"foo":"baz","bar":"qux"}

IMPORTANT CAVEAT You will need to change the default query string parser used by Fastify so that it produces a JavaScript object that will conform to the schema. See example.

fastify.route({
  method: 'GET',
  url: '/',
  schema: {
    querystring: {
      type: 'object',
      required: ['filter'],
      additionalProperties: false,
      properties: {
        filter: {
          type: 'object',
          required: ['foo'],
          properties: {
            foo: { type: 'string' },
            bar: { type: 'string' }
          },
          'x-consume': 'application/json'
        }
      }
    }
  },
  handler (request, reply) {
    reply.send(request.query.filter)
  }
})

Will generate this in the OpenAPI v3 schema's paths:

{
  "/": {
    "get": {
      "parameters": [
        {
          "in": "query",
          "name": "filter",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "foo"
                ],
                "properties": {
                  "foo": {
                    "type": "string"
                  },
                  "bar": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      ]
    }
  }
}

Links

Note: not supported by Swagger (OpenAPI v2), only OpenAPI v3

OpenAPI v3 Links are added by adding a links property to the top-level options of a route. See:

fastify.get('/user/:id', {
  schema: {
    params: {
      type: 'object',
      properties: {
        id: {
          type: 'string',
          description: 'the user identifier, as userId'
        }
      },
      required: ['id']
    },
    response: {
      200: {
        type: 'object',
        properties: {
          uuid: {
            type: 'string',
            format: 'uuid'
          }
        }
      }
    }
  },
  links: {
    // The status code must match the one in the response
    200: {
      address: {
        // See the OpenAPI documentation
        operationId: 'getUserAddress',
        parameters: {
          id: '$request.path.id'
        }
      }
    }
  }
}, () => {})

fastify.get('/user/:id/address', {
  schema: {
    operationId: 'getUserAddress',
    params: {
      type: 'object',
      properties: {
        id: {
          type: 'string',
          description: 'the user identifier, as userId'
        }
      },
      required: ['id']
    },
    response: {
      200: {
        type: 'string'
      }
    }
  }
}, () => {})

Hide a route

There are two ways to hide a route from the Swagger UI:

  • Pass { hide: true } to the schema object inside the route declaration.
  • Use the tag declared in hiddenTag options property inside the route declaration. Default is X-HIDDEN.

Swagger function options

Registering @fastify/swagger decorates the fastify instance with fastify.swagger(), which returns a JSON object representing the API. If { yaml: true } is passed to fastify.swagger() it will return a YAML string.

Integration

You can integration this plugin with @fastify/helmet with some little work.

@fastify/helmet options example:

.register(helmet, instance => {
  return {
    contentSecurityPolicy: {
      directives: {
        ...helmet.contentSecurityPolicy.getDefaultDirectives(),
        "form-action": ["'self'"],
        "img-src": ["'self'", "data:", "validator.swagger.io"],
        "script-src": ["'self'"].concat(instance.swaggerCSP.script),
        "style-src": ["'self'", "https:"].concat(
          instance.swaggerCSP.style
        ),
      }
    }
  }
})

Add examples to the schema

Note: OpenAPI and JSON Schema have different examples field formats.

Array with examples from JSON Schema converted to OpenAPI example or examples field automatically with generated names (example1, example2...):

fastify.route({
  method: 'POST',
  url: '/',
  schema: {
    querystring: {
      type: 'object',
      required: ['filter'],
      properties: {
        filter: {
          type: 'object',
          required: ['foo'],
          properties: {
            foo: { type: 'string' },
            bar: { type: 'string' }
          },
          examples: [
            { foo: 'bar', bar: 'baz' },
            { foo: 'foo', bar: 'bar' }
          ]
        }
      },
      examples: [
        { filter: { foo: 'bar', bar: 'baz' } }
      ]
    }
  },
  handler (request, reply) {
    reply.send(request.query.filter)
  }
})

Will generate this in the OpenAPI v3 schema's path:

"/": {
  "post": {
    "requestBody": {
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": ["filter"],
            "properties": {
              "filter": {
                "type": "object",
                "required": ["foo"],
                "properties": {
                  "foo": { "type": "string" },
                  "bar": { "type": "string" }
                },
                "examples": [{ "foo": "bar", "bar": "baz" }]
              }
            }
          },
          "examples": {
            "example1": {
              "value": { "filter": { "foo": "bar", "bar": "baz" } }
            },
            "example2": {
              "value": { "filter": { "foo": "foo", "bar": "bar" } }
            }
          }
        }
      },
      "required": true
    },
    "responses": { "200": { "description": "Default Response" } }
  }
}

If you want to set your own names or add descriptions to the examples of schemas, you can use x-examples field to set examples in OpenAPI format:

// Need to add a new allowed keyword to ajv in fastify instance
const fastify = Fastify({
  ajv: {
    plugins: [
      function (ajv) {
        ajv.addKeyword({ keyword: 'x-examples' })
      }
    ]
  }
})

fastify.route({
  method: 'POST',
  url: '/feed-animals',
  schema: {
    body: {
      type: 'object',
      required: ['animals'],
      properties: {
        animals: {
          type: 'array',
          items: {
            type: 'string'
          },
          minItems: 1,
        }
      },
      "x-examples": {
        Cats: {
          summary: "Feed cats",
          description: 
            "A longer **description** of the options with cats",
          value: { 
            animals: ["Tom", "Garfield", "Felix"] 
          }
        },
        Dogs: {
          summary: "Feed dogs",
          value: { 
            animals: ["Spike", "Odie", "Snoopy"] 
          }
        }
      }
    }
  },
  handler (request, reply) {
    reply.send(request.body.animals)
  }
})

$id and $ref usage

Development

In order to start development run:

npm i
npm run prepare

So that swagger-ui static folder will be generated for you.

How it works under the hood

@fastify/static serves swagger-ui static files, then calls /docs/json to get the Swagger file and render it.

How to work with $refs

The /docs/json endpoint in dynamic mode produces a single swagger.json file resolving all your

Acknowledgements

This project is kindly sponsored by:

License

Licensed under MIT.

More Repositories

1

fastify

Fast and low overhead web framework, for Node.js
JavaScript
29,975
star
2

fast-json-stringify

2x faster than JSON.stringify()
JavaScript
3,341
star
3

fastify-dx

Archived
JavaScript
909
star
4

fastify-vite

Fastify plugin for Vite integration.
JavaScript
795
star
5

fastify-cli

Run a Fastify application with one command!
JavaScript
605
star
6

benchmarks

Fast and low overhead web framework fastify benchmarks.
JavaScript
502
star
7

fluent-json-schema

A fluent API to generate JSON schemas
JavaScript
479
star
8

aws-lambda-fastify

Insipired by aws-serverless-express to work with Fastify with inject functionality.
JavaScript
479
star
9

fastify-nextjs

React server side rendering support for Fastify with Next
JavaScript
450
star
10

fastify-sensible

Defaults for Fastify that everyone can agree on
JavaScript
405
star
11

fastify-static

Plugin for serving static files as fast as possible
JavaScript
396
star
12

avvio

Asynchronous bootstrapping of Node applications
JavaScript
385
star
13

fastify-multipart

Multipart support for Fastify
JavaScript
343
star
14

fastify-jwt

JWT utils for Fastify
JavaScript
340
star
15

fastify-rate-limit

A low overhead rate limiter for your routes
JavaScript
335
star
16

fastify-http-proxy

Proxy your http requests to another server, with hooks.
JavaScript
310
star
17

fastify-helmet

Important security headers for Fastify
JavaScript
305
star
18

fastify-websocket

basic websocket support for fastify
JavaScript
290
star
19

fastify-cors

Fastify CORS
JavaScript
276
star
20

point-of-view

Template rendering plugin for Fastify
JavaScript
272
star
21

fastify-auth

Run multiple auth functions in Fastify
JavaScript
268
star
22

fastify-example-twitter

Fastify example - clone twitter
JavaScript
262
star
23

docs-chinese

Fastify δΈ­ζ–‡ζ–‡ζ‘£
253
star
24

light-my-request

Fake HTTP injection library
JavaScript
243
star
25

fastify-autoload

Require all plugins in a directory
JavaScript
242
star
26

under-pressure

Measure process load with automatic handling of "Service Unavailable" plugin for Fastify.
JavaScript
234
star
27

fastify-passport

Use passport strategies for authentication within a fastify application
TypeScript
234
star
28

fastify-oauth2

Enable to perform login using oauth2 protocol
JavaScript
229
star
29

fastify-cookie

A Fastify plugin to add cookies support
JavaScript
224
star
30

middie

Middleware engine for Fastify.
JavaScript
206
star
31

fastify-mongodb

Fastify MongoDB connection plugin
JavaScript
200
star
32

fastify-express

Express compatibility layer for Fastify
JavaScript
190
star
33

secure-json-parse

JSON.parse() drop-in replacement with prototype poisoning protection
JavaScript
176
star
34

fastify-env

Fastify plugin to check environment variables
JavaScript
175
star
35

fastify-caching

A Fastify plugin to facilitate working with cache headers
JavaScript
163
star
36

fast-proxy

Node.js framework agnostic library that enables you to forward an http request to another HTTP server. Supported protocols: HTTP, HTTPS, HTTP2
JavaScript
163
star
37

fastify-plugin

Plugin helper for Fastify
JavaScript
159
star
38

fastify-compress

Fastify compression utils
JavaScript
157
star
39

env-schema

Validate your env variable using Ajv and dotenv
JavaScript
154
star
40

fastify-redis

Plugin to share a common Redis connection across Fastify.
JavaScript
151
star
41

github-action-merge-dependabot

This action automatically approves and merges dependabot PRs.
JavaScript
151
star
42

fastify-secure-session

Create a secure stateless cookie session for Fastify
JavaScript
145
star
43

fastify-postgres

Fastify PostgreSQL connection plugin
JavaScript
145
star
44

fastify-reply-from

fastify plugin to forward the current http request to another server
JavaScript
142
star
45

fastify-request-context

Request-scoped storage support, based on Asynchronous Local Storage (with fallback to cls-hooked)
JavaScript
138
star
46

fastify-type-provider-typebox

A Type Provider for Typebox
TypeScript
136
star
47

fastify-bearer-auth

A Fastify plugin to require bearer Authorization headers
JavaScript
136
star
48

csrf-protection

A fastify csrf plugin.
JavaScript
127
star
49

fastify-formbody

A Fastify plugin to parse x-www-form-urlencoded bodies
JavaScript
125
star
50

fastify-circuit-breaker

A low overhead circuit breaker for your routes
JavaScript
113
star
51

fastify-swagger-ui

Serve Swagger-UI for Fastify
JavaScript
100
star
52

example

Runnable examples of Fastify
JavaScript
96
star
53

create-fastify

Rapidly generate a Fastify project
JavaScript
92
star
54

fastify-routes

Decorates fastify instance with a map of routes
JavaScript
91
star
55

session

Session plugin for fastify
JavaScript
89
star
56

restartable

Restart Fastify without losing a request
JavaScript
86
star
57

fastify-schedule

Fastify plugin for scheduling periodic jobs.
JavaScript
76
star
58

website-metalsmith

This project is used to build the website for fastify web framework and publish it online.
HTML
76
star
59

fastify-awilix

Dependency injection support for fastify
JavaScript
75
star
60

fastify-error

JavaScript
74
star
61

fast-uri

Dependency free RFC 3986 URI toolbox
JavaScript
74
star
62

fastify-hotwire

Use the Hotwire pattern with Fastify
JavaScript
69
star
63

fastify-etag

Automatically generate etags for HTTP responses, for Fastify
JavaScript
69
star
64

fastify-funky

Make fastify functional! Plugin, adding support for fastify routes returning functional structures, such as Either, Task or plain parameterless function.
JavaScript
68
star
65

fastify-example-todo

A Simple Fastify REST API Example
JavaScript
64
star
66

fastify-accepts

Add accepts parser to fastify
JavaScript
63
star
67

help

Need help with Fastify? File an Issue here.
61
star
68

fastify-basic-auth

Fastify basic auth plugin
JavaScript
59
star
69

fastify-mysql

JavaScript
57
star
70

busboy

A streaming parser for HTML form data for node.js
JavaScript
56
star
71

fastify-url-data

A plugin to provide access to the raw URL components
JavaScript
55
star
72

releasify

A tool to release in a simpler way your module
JavaScript
55
star
73

fastify-kafka

Fastify plugin to interact with Apache Kafka.
JavaScript
51
star
74

fastify-elasticsearch

Fastify plugin for Elasticsearch
JavaScript
40
star
75

fastify-routes-stats

provide stats for routes using perf_hooks, for fastify
JavaScript
40
star
76

deepmerge

Merges the enumerable properties of two or more objects deeply. Fastest implementation of deepmerge
JavaScript
39
star
77

manifetch

A manifest-based fetch() API client builder.
JavaScript
37
star
78

fastify-response-validation

A simple plugin that enables response validation for Fastify.
JavaScript
36
star
79

fastify-type-provider-json-schema-to-ts

A Type Provider for json-schema-to-ts
TypeScript
32
star
80

skeleton

Template repository to create standardized Fastify plugins.
31
star
81

fastify-accepts-serializer

Serializer according to the accept header
JavaScript
24
star
82

website

JavaScript
24
star
83

fastify-leveldb

Plugin to share a common LevelDB connection across Fastify.
JavaScript
21
star
84

tsconfig

Shared TypeScript configuration for fastify projects
21
star
85

fastify-flash

Flash message plugin for Fastify
TypeScript
20
star
86

process-warning

A small utility for creating warnings and emitting them.
JavaScript
19
star
87

docs-korean

18
star
88

one-line-logger

JavaScript
18
star
89

fastify-api

A radically simple API routing and method injection plugin for Fastify.
JavaScript
18
star
90

ajv-compiler

Build and manage the AJV instances for the fastify framework
JavaScript
17
star
91

fastify-early-hints

Draft plugin of the HTTP 103 implementation
JavaScript
17
star
92

vite-plugin-blueprint

Vite plugin for shadowing files from a blueprint folder.
JavaScript
17
star
93

fastify-bankai

Bankai assets compiler for Fastify
JavaScript
15
star
94

fastify-diagnostics-channel

Plugin to deal with diagnostics_channel on Fastify
JavaScript
14
star
95

csrf

CSRF utilities for fastify
JavaScript
13
star
96

.github

Default community health files
13
star
97

any-schema-you-like

Save multiple schemas and decide which one to use to serialize the payload
JavaScript
13
star
98

fastify-throttle

Throttle the download speed of a request
JavaScript
12
star
99

fastify-typescript-extended-sample

This project is supposed to be a large, fake Fastify & TypeScript app. It is meant to be a reference as well as a pseudo-sandbox for Fastify TypeScript changes.
TypeScript
11
star
100

fastify-soap-client

Fastify plugin for a SOAP client
JavaScript
10
star