Fastify 中文文档 (latest — v4.27.0)

Contributing To Fastify

Thank you for taking an interest in contributing to Fastify. We are excited to receive your support and knowledge. This guide is our attempt to help you help us.


This is an informal guide. Please review the formal CONTRIBUTING document for full details and our Developer Certificate of Origin.

Table Of Contents

Types Of Contributions We're Looking For

In short, we welcome any type of contribution you are willing to provide. No contribution is too small. We gladly accept contributions such as:

  • Documentation improvements: from small typo corrections to major document reworks
  • Helping others by answering questions in pull requests and discussions
  • Fixing known bugs
  • Reporting previously unknown bugs by opening an issue with a minimal reproduction

Ground Rules & Expectations

Before we get started, here are a few things we expect from you (and that you should expect from others):

  • Be respectful and thoughtful in your conversations around this project. This project is maintained by a diverse set of people from all across the globe. Each person has their own views and opinions about the project. Try to listen to each other and reach an agreement or compromise.
  • We have a Code of Conduct. You must adhere to it to participate in this project.
  • If you open a pull request, please ensure that your contribution passes all tests. If there are test failures, you will need to address them before we can merge your contribution.

How To Contribute

If you'd like to contribute, start by searching through the issues and pull requests to see whether someone else has raised a similar idea or question.

If you don't see your idea listed, and you think it fits into the goals of this guide, do one of the following:

  • If your contribution is minor, such as a typo fix, open a pull request.
  • If your contribution is major, such as a new feature, start by opening an issue first. That way, other people can weigh in on the discussion before you do any work.

Setting Up Your Environment

Please adhere to the project's code and documentation style. Some popular tools that automatically "correct" code and documentation do not follow a style that conforms to the styles this project uses. Notably, this project uses StandardJS for code formatting.


Using Visual Studio Code

What follows is how to use Visual Studio Code (VSCode) portable to create a Fastify specific environment. This guide is written as if you are setting up the environment on macOS, but the principles are the same across all platforms. See the previously linked VSCode portable guide for help with other platforms.

First, download VSCode and unpackage it to /Applications/VSCodeFastify/. Upon doing so, the following should output "found" when run in a terminal:

[ -d /Applications/VSCodeFastify/Visual\ Studio\ ] && echo "found"

As mentioned in the VSCode portable guide, we need to unsandbox the application for the portable mode to work correctly. So issue the following in a terminal:

xattr -dr /Applications/VSCodeFastify/Visual\ Studio\

Next, create the required data directories for VSCode:

mkdir -p /Applications/VSCodeFastify/code-portable-data/{user-data,extensions}

Before continuing, we need to add the code command to your terminal's PATH. To do so, we will manually add VSCode to the PATH. As outlined in that document, the instructions vary depending on your default shell, so you should follow the instructions in that guide as relates to your preferred shell. However, we will tweak them slightly by defining an alias instead of a direct reference to the code tool. This is so we do not conflict with any other installation of VSCode you may have, and to keep this guide specific to Fastify. So, ultimately, we want the following:

alias code-fastify="/Applications/VSCodeFastify/Visual\ Studio\"

The result should be that code-fastify --version results in something like:

❯ code-fastify --version

Now that VSCode is installed, and we can work with it via the command line, we need to install an extension that will aid in keeping any JavaScript you write for the project formatted according to the project's style:

code-fastify --install-extension dbaeumer.vscode-eslint

Upon successful execution of the previous command, the following command should result in "found" being output:

[ -d /Applications/VSCodeFastify/code-portable-data/extensions/dbaeumer.vscode-eslint-* ] && echo "found"

Now, from within the directory of your local clone of the Fastify project, we can open VSCode:

code-fastify .

A new VSCode window should open and you should see the Fastify project files in the left sidebar. But wait! We are not quite done yet. There are a few more baseline settings that should be set before VSCode is ready.

Press cmd+shift+p to bring up the VSCode command input prompt. Type open settings (json). Three VSCode Setting options will appear in the dropdown: Workspace, Default, and User settings. We recommend selecting Default. This will open a document that is the settings for the editor. Paste the following JSON into this document, overwriting any text already present, and save it:

    "[javascript]": {
        "editor.defaultFormatter": "dbaeumer.vscode-eslint",
        "editor.codeActionsOnSave": {
            "source.fixAll": true

    "workbench.colorCustomizations": {
        "statusBar.background": "#178bb9"

Finally, from the menu bar, select "Terminal > New Terminal" to open a new terminal in the editor. Run npm i to install the Fastify dependencies.

At this point, you are all setup with a custom VSCode instance that can be used to work on Fastify contributions. As you edit and save JavaScript files, the editor will autocorrect any style issues.