Skip to content

Commit

Permalink
Merge branch 'main' into (fastify#4439)-Access-handler-name-add-prope…
Browse files Browse the repository at this point in the history
…rties-to-req-route-options
  • Loading branch information
Eomm committed May 14, 2023
2 parents acc8b31 + 42685f4 commit b9ad2b5
Show file tree
Hide file tree
Showing 73 changed files with 3,343 additions and 2,148 deletions.
3 changes: 3 additions & 0 deletions .github/labeler.yml
Expand Up @@ -2,6 +2,9 @@
documentation:
- all: ["docs/**/*"]

"github actions":
- all: [".github/workflows/*"]

# PRs that only touch type files
typescript:
- all: ["**/*[.|-]d.ts"]
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/benchmark-parser.yml
@@ -0,0 +1,96 @@
name: Benchmark-parser

on:
pull_request_target:
types: [labeled]

jobs:
benchmark:
if: ${{ github.event.label.name == 'benchmark' }}
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
PR-BENCH-14: ${{ steps.benchmark-pr.outputs.BENCH_RESULT14 }}
PR-BENCH-16: ${{ steps.benchmark-pr.outputs.BENCH_RESULT16 }}
PR-BENCH-18: ${{ steps.benchmark-pr.outputs.BENCH_RESULT18 }}
MAIN-BENCH-14: ${{ steps.benchmark-main.outputs.BENCH_RESULT14 }}
MAIN-BENCH-16: ${{ steps.benchmark-main.outputs.BENCH_RESULT16 }}
MAIN-BENCH-18: ${{ steps.benchmark-main.outputs.BENCH_RESULT18 }}
strategy:
matrix:
node-version: [14, 16, 18]
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: |
npm install --only=production --ignore-scripts
- name: Run benchmark
id: benchmark-pr
run: |
npm run --silent benchmark:parser > ./bench-result.md
result=$(awk '/requests in/' ./bench-result.md)
echo "::set-output name=BENCH_RESULT${{matrix.node-version}}::$result"
# main benchmark
- uses: actions/checkout@v3
with:
persist-credentials: false
ref: 'main'

- name: Install
run: |
npm install --only=production --ignore-scripts
- name: Run benchmark
id: benchmark-main
run: |
npm run --silent benchmark:parser > ./bench-result.md
result=$(awk '/requests in/' ./bench-result.md)
echo "::set-output name=BENCH_RESULT${{matrix.node-version}}::$result"
output-benchmark:
needs: [benchmark]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: |
**Node**: 14
**Type**: Parser
**PR**: ${{ needs.benchmark.outputs.PR-BENCH-14 }}
**MAIN**: ${{ needs.benchmark.outputs.MAIN-BENCH-14 }}
---
**Node**: 16
**Type**: Parser
**PR**: ${{ needs.benchmark.outputs.PR-BENCH-16 }}
**MAIN**: ${{ needs.benchmark.outputs.MAIN-BENCH-16 }}
---
**Node**: 18
**Type**: Parser
**PR**: ${{ needs.benchmark.outputs.PR-BENCH-18 }}
**MAIN**: ${{ needs.benchmark.outputs.MAIN-BENCH-18 }}
- uses: actions-ecosystem/action-remove-labels@v1
with:
labels: |
benchmark
github_token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -2,6 +2,11 @@ name: ci

on:
push:
branches:
- main
- master
- next
- 'v*'
paths-ignore:
- 'docs/**'
- '*.md'
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/integration.yml
Expand Up @@ -2,6 +2,11 @@ name: integration

on:
push:
branches:
- main
- master
- next
- 'v*'
paths-ignore:
- 'docs/**'
- '*.md'
Expand All @@ -18,8 +23,14 @@ jobs:

strategy:
matrix:
node-version: [14, 16, 18]
node-version: [16, 18]
os: [ubuntu-latest]
pnpm-version: [8]
# pnpm@8 does not support Node.js 14 so include it separately
include:
- node-version: 14
os: ubuntu-latest
pnpm-version: 7

steps:
- uses: actions/checkout@v3
Expand All @@ -32,8 +43,9 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Install Pnpm
run: |
npm i -g pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm-version }}

- name: Install Production
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/labeler.yml
Expand Up @@ -11,4 +11,6 @@ jobs:
steps:
- uses: actions/labeler@v4
with:
# Workaround only valid until the next major version bump (v5)
sync-labels: ''
repo-token: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/links-check.yml
Expand Up @@ -19,7 +19,7 @@ jobs:
# See: https://github.com/lycheeverse/lychee-action/issues/17
- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@9ace499fe66cee282a29eaa628fdac2c72fa087f
uses: lycheeverse/lychee-action@97189f2c0a3c8b0cb0e704fd4e878af6e5e2b2c5
with:
fail: true
# As external links behaviour is not predictable, we check only internal links
Expand Down
18 changes: 14 additions & 4 deletions .github/workflows/package-manager-ci.yml
Expand Up @@ -15,8 +15,14 @@ jobs:
strategy:
matrix:
# Maintenance and active LTS
node-version: [14, 16, 18]
node-version: [16, 18]
os: [ubuntu-latest]
pnpm-version: [8]
# pnpm@8 does not support Node.js 14 so include it separately
include:
- node-version: 14
os: ubuntu-latest
pnpm-version: 7

steps:
- uses: actions/checkout@v3
Expand All @@ -29,9 +35,11 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Install with pnpm
run: |
curl -L https://unpkg.com/@pnpm/self-installer | node
pnpm install
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm-version }}

- run: pnpm install

- name: Run tests
run: |
Expand Down Expand Up @@ -61,6 +69,8 @@ jobs:
curl -o- -L https://yarnpkg.com/install.sh | bash
yarn install --ignore-engines
- run: yarn

- name: Run tests
run: |
yarn run test:ci
18 changes: 18 additions & 0 deletions .github/workflows/test-compare.yml
@@ -0,0 +1,18 @@
name: Test compare
on:
pull_request:
types: [opened, reopened, synchronize, labeled]

jobs:
run:
if: contains(github.event.pull_request.labels.*.name, 'test-compare')
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Test compare
uses: nearform-actions/github-action-test-compare@v1
with:
label: test-compare
testCommand: 'npm run test:ci'
6 changes: 5 additions & 1 deletion .github/workflows/website.yml
Expand Up @@ -19,4 +19,8 @@ jobs:
steps:
- name: Build website
run: |
curl -X POST --header 'Content-Type: application/json' "https://circleci.com/api/v1.1/project/github/fastify/website?circle-token=${{ secrets.circleci_token }}"
curl -X POST \
-H 'Content-Type: application/json' \
-H 'Circle-Token: ${{ secrets.circleci_token }}' \
-d '{"branch":"master"}' \
"https://circleci.com/api/v2/project/gh/fastify/website/pipeline"
4 changes: 2 additions & 2 deletions GOVERNANCE.md
Expand Up @@ -14,8 +14,8 @@

## Lead Maintainers

Fastify Lead Maintainers are the founder of the project and the organization
owners. They are the only members of the `@fastify/leads` team. The Lead
Fastify Lead Maintainers are the organization owners.
They are the only members of the `@fastify/leads` team. The Lead
Maintainers are the curator of the Fastify project and their key responsibility
is to issue releases of Fastify and its dependencies.

Expand Down
29 changes: 16 additions & 13 deletions README.md
Expand Up @@ -9,11 +9,11 @@

<div align="center">

[![CI](https://github.com/fastify/fastify/workflows/ci/badge.svg)](https://github.com/fastify/fastify/actions/workflows/ci.yml)
[![CI](https://github.com/fastify/fastify/workflows/ci/badge.svg?branch=main)](https://github.com/fastify/fastify/actions/workflows/ci.yml)
[![Package Manager
CI](https://github.com/fastify/fastify/workflows/package-manager-ci/badge.svg)](https://github.com/fastify/fastify/actions/workflows/package-manager-ci.yml)
CI](https://github.com/fastify/fastify/workflows/package-manager-ci/badge.svg?branch=main)](https://github.com/fastify/fastify/actions/workflows/package-manager-ci.yml)
[![Web
SIte](https://github.com/fastify/fastify/workflows/website/badge.svg)](https://github.com/fastify/fastify/actions/workflows/website.yml)
SIte](https://github.com/fastify/fastify/workflows/website/badge.svg?branch=main)](https://github.com/fastify/fastify/actions/workflows/website.yml)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)

</div>
Expand All @@ -38,6 +38,18 @@ resources of your server, knowing that you are serving the highest number of
requests as possible, without sacrificing security validations and handy
development?

Enter Fastify. Fastify is a web framework highly focused on providing the best
developer experience with the least overhead and a powerful plugin architecture.
It is inspired by Hapi and Express and as far as we know, it is one of the
fastest web frameworks in town.

The `main` branch refers to the Fastify `v4` release. Check out the
[`v3.x` branch](https://github.com/fastify/fastify/tree/3.x) for `v3`.



### Table of Contents

- [Quick start](#quick-start)
- [Install](#install)
- [Example](#example)
Expand All @@ -51,13 +63,6 @@ development?
- [Hosted by](#hosted-by)
- [License](#license)

Enter Fastify. Fastify is a web framework highly focused on providing the best
developer experience with the least overhead and a powerful plugin architecture.
It is inspired by Hapi and Express and as far as we know, it is one of the
fastest web frameworks in town.

This branch refers to the Fastify v4 release. Check out the
[v3.x](https://github.com/fastify/fastify/tree/v3.x) branch for v3.

### Quick start

Expand Down Expand Up @@ -189,7 +194,7 @@ changes should be based on **`branch 1.x`**. In a similar way, all Fastify
- **Highly performant:** as far as we know, Fastify is one of the fastest web
frameworks in town, depending on the code complexity we can serve up to 76+
thousand requests per second.
- **Extendible:** Fastify is fully extensible via its hooks, plugins and
- **Extensible:** Fastify is fully extensible via its hooks, plugins and
decorators.
- **Schema based:** even if it is not mandatory we recommend to use [JSON
Schema](https://json-schema.org/) to validate your routes and serialize your
Expand Down Expand Up @@ -339,8 +344,6 @@ listed in alphabetical order.
* [__Frazer Smith__](https://github.com/Fdawgs), <https://www.npmjs.com/~fdawgs>
* [__Manuel Spigolon__](https://github.com/eomm),
<https://twitter.com/manueomm>, <https://www.npmjs.com/~eomm>
* [__Rafael Gonzaga__](https://github.com/rafaelgss),
<https://twitter.com/_rafaelgss>, <https://www.npmjs.com/~rafaelgss>
* [__Simone Busoli__](https://github.com/simoneb),
<https://twitter.com/simonebu>, <https://www.npmjs.com/~simoneb>

Expand Down
15 changes: 7 additions & 8 deletions docs/Guides/Database.md
Expand Up @@ -130,19 +130,18 @@ fastify.register(require('@fastify/mongodb'), {
url: 'mongodb://mongo/mydb'
})

fastify.get('/user/:id', function (req, reply) {
fastify.get('/user/:id', async function (req, reply) {
// Or this.mongo.client.db('mydb').collection('users')
const users = this.mongo.db.collection('users')

// if the id is an ObjectId format, you need to create a new ObjectId
const id = this.mongo.ObjectId(req.params.id)
users.findOne({ id }, (err, user) => {
if (err) {
reply.send(err)
return
}
reply.send(user)
})
try {
const user = await users.findOne({ id })
return user
} catch (err) {
return err
}
})

fastify.listen({ port: 3000 }, err => {
Expand Down

0 comments on commit b9ad2b5

Please sign in to comment.