strong-tie/inbound-calls
0
1<div align="center"> <a href="https://fastify.dev/">2 <img3 src="https://github.com/fastify/graphics/raw/HEAD/fastify-landscape-outlined.svg"4 width="650"5 height="auto"6 />7 </a>8</div>9 10<div align="center">11 12[](https://github.com/fastify/fastify/actions/workflows/ci.yml)13[](https://github.com/fastify/fastify/actions/workflows/package-manager-ci.yml)15[](https://github.com/fastify/fastify/actions/workflows/website.yml)17[](https://github.com/neostandard/neostandard)18[](https://bestpractices.coreinfrastructure.org/projects/7585)19 20</div>21 22<div align="center">23 24[](https://www.npmjs.com/package/fastify)26[](https://www.npmjs.com/package/fastify)28[](https://github.com/fastify/fastify/blob/main/SECURITY.md)30[](https://discord.gg/fastify)31[](https://gitpod.io/#https://github.com/fastify/fastify)32[](https://github.com/sponsors/fastify#sponsors)33 34</div>35 36<br />37 38An efficient server implies a lower cost of the infrastructure, a better39responsiveness under load and happy users. How can you efficiently handle the40resources of your server, knowing that you are serving the highest number of41requests as possible, without sacrificing security validations and handy42development?43 44Enter Fastify. Fastify is a web framework highly focused on providing the best45developer experience with the least overhead and a powerful plugin architecture.46It is inspired by Hapi and Express and as far as we know, it is one of the47fastest web frameworks in town.48 49The `main` branch refers to the Fastify `v5` release, which is not released/LTS yet.50Check out the [`4.x` branch](https://github.com/fastify/fastify/tree/4.x) for `v4`.51 52### Table of Contents53 54 - [Quick start](#quick-start)55 - [Install](#install)56 - [Example](#example)57 - [Core features](#core-features)58 - [Benchmarks](#benchmarks)59 - [Documentation](#documentation)60 - [Ecosystem](#ecosystem)61 - [Support](#support)62 - [Team](#team)63 - [Hosted by](#hosted-by)64 - [License](#license)65 66 67### Quick start68 69Create a folder and make it your current working directory:70 71```sh72mkdir my-app73cd my-app74```75 76Generate a fastify project with `npm init`:77 78```sh79npm init fastify80```81 82Install dependencies:83 84```sh85npm i86```87 88To start the app in dev mode:89 90```sh91npm run dev92```93 94For production mode:95 96```sh97npm start98```99 100Under the hood `npm init` downloads and runs [Fastify101Create](https://github.com/fastify/create-fastify), which in turn uses the102generate functionality of [Fastify CLI](https://github.com/fastify/fastify-cli).103 104 105### Install106 107To install Fastify in an existing project as a dependency:108 109```sh110npm i fastify111```112 113### Example114 115```js116// Require the framework and instantiate it117 118// ESM119import Fastify from 'fastify'120 121const fastify = Fastify({122 logger: true123})124// CommonJs125const fastify = require('fastify')({126 logger: true127})128 129// Declare a route130fastify.get('/', (request, reply) => {131 reply.send({ hello: 'world' })132})133 134// Run the server!135fastify.listen({ port: 3000 }, (err, address) => {136 if (err) throw err137 // Server is now listening on ${address}138})139```140 141with async-await:142 143```js144// ESM145import Fastify from 'fastify'146 147const fastify = Fastify({148 logger: true149})150// CommonJs151const fastify = require('fastify')({152 logger: true153})154 155fastify.get('/', async (request, reply) => {156 reply.type('application/json').code(200)157 return { hello: 'world' }158})159 160fastify.listen({ port: 3000 }, (err, address) => {161 if (err) throw err162 // Server is now listening on ${address}163})164```165 166Do you want to know more? Head to the <a167href="./docs/Guides/Getting-Started.md"><code><b>Getting Started</b></code></a>.168 169> ## Note170> `.listen` binds to the local host, `localhost`, interface by default171> (`127.0.0.1` or `::1`, depending on the operating system configuration). If172> you are running Fastify in a container (Docker,173> [GCP](https://cloud.google.com/), etc.), you may need to bind to `0.0.0.0`. Be174> careful when deciding to listen on all interfaces; it comes with inherent175> [security176> risks](https://web.archive.org/web/20170711105010/https://snyk.io/blog/mongodb-hack-and-secure-defaults/).177> See [the documentation](./docs/Reference/Server.md#listen) for more178> information.179 180### Core features181 182- **Highly performant:** as far as we know, Fastify is one of the fastest web183 frameworks in town, depending on the code complexity we can serve up to 76+184 thousand requests per second.185- **Extensible:** Fastify is fully extensible via its hooks, plugins and186 decorators.187- **Schema based:** even if it is not mandatory we recommend to use [JSON188 Schema](https://json-schema.org/) to validate your routes and serialize your189 outputs, internally Fastify compiles the schema in a highly performant190 function.191- **Logging:** logs are extremely important but are costly; we chose the best192 logger to almost remove this cost, [Pino](https://github.com/pinojs/pino)!193- **Developer friendly:** the framework is built to be very expressive and help194 the developer in their daily use, without sacrificing performance and195 security.196 197### Benchmarks198 199__Machine:__ EX41S-SSD, Intel Core i7, 4Ghz, 64GB RAM, 4C/8T, SSD.200 201__Method:__: `autocannon -c 100 -d 40 -p 10 localhost:3000` * 2, taking the202second average203 204| Framework | Version | Router? | Requests/sec |205| :----------------- | :------------------------- | :----------: | ------------: |206| Express | 4.17.3 | ✓ | 14,200 |207| hapi | 20.2.1 | ✓ | 42,284 |208| Restify | 8.6.1 | ✓ | 50,363 |209| Koa | 2.13.0 | ✗ | 54,272 |210| **Fastify** | **4.0.0** | **✓** | **77,193** |211| - | | | |212| `http.Server` | 16.14.2 | ✗ | 74,513 |213 214Benchmarks taken using https://github.com/fastify/benchmarks. This is a215synthetic, "hello world" benchmark that aims to evaluate the framework overhead.216The overhead that each framework has on your application depends on your217application, you should __always__ benchmark if performance matters to you.218 219## Documentation220* [__`Getting Started`__](./docs/Guides/Getting-Started.md)221* [__`Guides`__](./docs/Guides/Index.md)222* [__`Server`__](./docs/Reference/Server.md)223* [__`Routes`__](./docs/Reference/Routes.md)224* [__`Encapsulation`__](./docs/Reference/Encapsulation.md)225* [__`Logging`__](./docs/Reference/Logging.md)226* [__`Middleware`__](./docs/Reference/Middleware.md)227* [__`Hooks`__](./docs/Reference/Hooks.md)228* [__`Decorators`__](./docs/Reference/Decorators.md)229* [__`Validation and Serialization`__](./docs/Reference/Validation-and-Serialization.md)230* [__`Fluent Schema`__](./docs/Guides/Fluent-Schema.md)231* [__`Lifecycle`__](./docs/Reference/Lifecycle.md)232* [__`Reply`__](./docs/Reference/Reply.md)233* [__`Request`__](./docs/Reference/Request.md)234* [__`Errors`__](./docs/Reference/Errors.md)235* [__`Content Type Parser`__](./docs/Reference/ContentTypeParser.md)236* [__`Plugins`__](./docs/Reference/Plugins.md)237* [__`Testing`__](./docs/Guides/Testing.md)238* [__`Benchmarking`__](./docs/Guides/Benchmarking.md)239* [__`How to write a good plugin`__](./docs/Guides/Write-Plugin.md)240* [__`Plugins Guide`__](./docs/Guides/Plugins-Guide.md)241* [__`HTTP2`__](./docs/Reference/HTTP2.md)242* [__`Long Term Support`__](./docs/Reference/LTS.md)243* [__`TypeScript and types support`__](./docs/Reference/TypeScript.md)244* [__`Serverless`__](./docs/Guides/Serverless.md)245* [__`Recommendations`__](./docs/Guides/Recommendations.md)246 247中文文档[地址](https://github.com/fastify/docs-chinese/blob/HEAD/README.md)248 249## Ecosystem250 251- [Core](./docs/Guides/Ecosystem.md#core) - Core plugins maintained by the252 _Fastify_ [team](#team).253- [Community](./docs/Guides/Ecosystem.md#community) - Community supported254 plugins.255- [Live Examples](https://github.com/fastify/example) - Multirepo with a broad256 set of real working examples.257- [Discord](https://discord.gg/D3FZYPy) - Join our discord server and chat with258 the maintainers.259 260## Support261Please visit [Fastify help](https://github.com/fastify/help) to view prior262support issues and to ask new support questions.263 264Version 3 of Fastify and lower are EOL and will not receive any security or bug fixes.265 266Fastify's partner, HeroDevs, provides commercial security fixes for all267unsupported versions at [https://herodevs.com/support/fastify-nes][hd-link].268Fastify's supported version matrix is available in the269[Long Term Support][lts-link] documentation.270 271## Contributing272 273Whether reporting bugs, discussing improvements and new ideas or writing code,274we welcome contributions from anyone and everyone. Please read the [CONTRIBUTING](./CONTRIBUTING.md)275guidelines before submitting pull requests.276 277## Team278 279_Fastify_ is the result of the work of a great community. Team members are280listed in alphabetical order.281 282**Lead Maintainers:**283* [__Matteo Collina__](https://github.com/mcollina),284 <https://twitter.com/matteocollina>, <https://www.npmjs.com/~matteo.collina>285* [__Tomas Della Vedova__](https://github.com/delvedor),286 <https://twitter.com/delvedor>, <https://www.npmjs.com/~delvedor>287* [__KaKa Ng__](https://github.com/climba03003),288 <https://www.npmjs.com/~climba03003>289* [__Manuel Spigolon__](https://github.com/eomm),290 <https://twitter.com/manueomm>, <https://www.npmjs.com/~eomm>291* [__James Sumners__](https://github.com/jsumners),292 <https://twitter.com/jsumners79>, <https://www.npmjs.com/~jsumners>293 294### Fastify Core team295* [__Aras Abbasi__](https://github.com/uzlopak),296 <https://www.npmjs.com/~uzlopak>297* [__Harry Brundage__](https://github.com/airhorns/),298 <https://twitter.com/harrybrundage>, <https://www.npmjs.com/~airhorns>299* [__Matteo Collina__](https://github.com/mcollina),300 <https://twitter.com/matteocollina>, <https://www.npmjs.com/~matteo.collina>301* [__Gürgün Dayıoğlu__](https://github.com/gurgunday),302 <https://www.npmjs.com/~gurgunday>303* [__Tomas Della Vedova__](https://github.com/delvedor),304 <https://twitter.com/delvedor>, <https://www.npmjs.com/~delvedor>305* [__Carlos Fuentes__](https://github.com/metcoder95),306 <https://twitter.com/metcoder95>, <https://www.npmjs.com/~metcoder95>307* [__Vincent Le Goff__](https://github.com/zekth)308* [__Luciano Mammino__](https://github.com/lmammino),309 <https://twitter.com/loige>, <https://www.npmjs.com/~lmammino>310* [__KaKa Ng__](https://github.com/climba03003),311 <https://www.npmjs.com/~climba03003>312* [__Luis Orbaiceta__](https://github.com/luisorbaiceta),313 <https://twitter.com/luisorbai>, <https://www.npmjs.com/~luisorbaiceta>314* [__Maksim Sinik__](https://github.com/fox1t),315 <https://twitter.com/maksimsinik>, <https://www.npmjs.com/~fox1t>316* [__Manuel Spigolon__](https://github.com/eomm),317 <https://twitter.com/manueomm>, <https://www.npmjs.com/~eomm>318* [__James Sumners__](https://github.com/jsumners),319 <https://twitter.com/jsumners79>, <https://www.npmjs.com/~jsumners>320 321### Fastify Plugins team322* [__Harry Brundage__](https://github.com/airhorns/),323 <https://twitter.com/harrybrundage>, <https://www.npmjs.com/~airhorns>324* [__Simone Busoli__](https://github.com/simoneb),325 <https://twitter.com/simonebu>, <https://www.npmjs.com/~simoneb>326* [__Dan Castillo__](https://github.com/dancastillo),327 <https://www.npmjs.com/~dancastillo>328* [__Matteo Collina__](https://github.com/mcollina),329 <https://twitter.com/matteocollina>, <https://www.npmjs.com/~matteo.collina>330* [__Gürgün Dayıoğlu__](https://github.com/gurgunday),331 <https://www.npmjs.com/~gurgunday>332* [__Tomas Della Vedova__](https://github.com/delvedor),333 <https://twitter.com/delvedor>, <https://www.npmjs.com/~delvedor>334* [__Carlos Fuentes__](https://github.com/metcoder95),335 <https://twitter.com/metcoder95>, <https://www.npmjs.com/~metcoder95>336* [__Vincent Le Goff__](https://github.com/zekth)337* [__Jean Michelet__](https://github.com/jean-michelet),338 <https://www.npmjs.com/~jean-michelet>339* [__KaKa Ng__](https://github.com/climba03003),340 <https://www.npmjs.com/~climba03003>341* [__Maksim Sinik__](https://github.com/fox1t),342 <https://twitter.com/maksimsinik>, <https://www.npmjs.com/~fox1t>343* [__Frazer Smith__](https://github.com/Fdawgs), <https://www.npmjs.com/~fdawgs>344* [__Manuel Spigolon__](https://github.com/eomm),345 <https://twitter.com/manueomm>, <https://www.npmjs.com/~eomm>346 347### Emeritus Contributors348Great contributors on a specific area in the Fastify ecosystem will be invited349to join this group by Lead Maintainers when they decide to step down from the350active contributors group.351 352* [__Tommaso Allevi__](https://github.com/allevo),353 <https://twitter.com/allevitommaso>, <https://www.npmjs.com/~allevo>354* [__Ethan Arrowood__](https://github.com/Ethan-Arrowood/),355 <https://twitter.com/arrowoodtech>, <https://www.npmjs.com/~ethan_arrowood>356* [__Çağatay Çalı__](https://github.com/cagataycali),357 <https://twitter.com/cagataycali>, <https://www.npmjs.com/~cagataycali>358* [__David Mark Clements__](https://github.com/davidmarkclements),359 <https://twitter.com/davidmarkclem>,360 <https://www.npmjs.com/~davidmarkclements>361* [__dalisoft__](https://github.com/dalisoft), <https://twitter.com/dalisoft>,362 <https://www.npmjs.com/~dalisoft>363* [__Dustin Deus__](https://github.com/StarpTech),364 <https://twitter.com/dustindeus>, <https://www.npmjs.com/~starptech>365* [__Denis Fäcke__](https://github.com/SerayaEryn),366 <https://twitter.com/serayaeryn>, <https://www.npmjs.com/~serayaeryn>367* [__Rafael Gonzaga__](https://github.com/rafaelgss),368 <https://twitter.com/_rafaelgss>, <https://www.npmjs.com/~rafaelgss>369* [__Trivikram Kamat__](https://github.com/trivikr),370 <https://twitter.com/trivikram>, <https://www.npmjs.com/~trivikr>371* [__Ayoub El Khattabi__](https://github.com/AyoubElk),372 <https://twitter.com/ayoubelkh>, <https://www.npmjs.com/~ayoubelk>373* [__Cemre Mengu__](https://github.com/cemremengu),374 <https://twitter.com/cemremengu>, <https://www.npmjs.com/~cemremengu>375* [__Salman Mitha__](https://github.com/salmanm),376 <https://www.npmjs.com/~salmanm>377* [__Nathan Woltman__](https://github.com/nwoltman),378 <https://twitter.com/NathanWoltman>, <https://www.npmjs.com/~nwoltman>379 380## Hosted by381 382[<img383src="https://github.com/openjs-foundation/artwork/blob/main/openjs_foundation/openjs_foundation-logo-horizontal-color.png?raw=true"384width="250px;"/>](https://openjsf.org/projects)385 386We are a [At-Large387Project](https://github.com/openjs-foundation/cross-project-council/blob/HEAD/PROJECT_PROGRESSION.md#at-large-projects)388in the [OpenJS Foundation](https://openjsf.org/).389 390## Sponsors391 392Support this project by becoming a [SPONSOR](./SPONSORS.md)!393Fastify has an [Open Collective](https://opencollective.com/fastify)394page where we accept and manage financial contributions.395 396## Acknowledgements397 398This project is kindly sponsored by:399- [NearForm](https://nearform.com)400- [Platformatic](https://platformatic.dev)401 402Past Sponsors:403- [LetzDoIt](https://www.letzdoitapp.com/)404 405This list includes all companies that support one or more of the team members406in the maintenance of this project.407 408## License409 410Licensed under [MIT](./LICENSE).411 412For your convenience, here is a list of all the licenses of our production413dependencies:414- MIT415- ISC416- BSD-3-Clause417- BSD-2-Clause418 419[hd-link]: https://www.herodevs.com/support/fastify-nes?utm_source=fastify&utm_medium=link&utm_campaign=github_readme420[lts-link]: https://fastify.dev/docs/latest/Reference/LTS/421 