@fastify/express 4.0.7 → 4.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,7 +27,7 @@ jobs:
27
27
  permissions:
28
28
  contents: write
29
29
  pull-requests: write
30
- uses: fastify/workflows/.github/workflows/plugins-ci.yml@v6
30
+ uses: fastify/workflows/.github/workflows/plugins-ci.yml@ef591e2186785d5ab36b9fe6a79c7ce2f1d94e57 # v7.0.0
31
31
  with:
32
32
  license-check: true
33
33
  lint: true
@@ -16,4 +16,4 @@ jobs:
16
16
  permissions:
17
17
  issues: write
18
18
  pull-requests: write
19
- uses: fastify/workflows/.github/workflows/lock-threads.yml@v6
19
+ uses: fastify/workflows/.github/workflows/lock-threads.yml@ef591e2186785d5ab36b9fe6a79c7ce2f1d94e57 # v7.0.0
@@ -0,0 +1,24 @@
1
+ name: Release the package
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ semver:
7
+ description: 'Release bump type'
8
+ required: true
9
+ type: choice
10
+ options:
11
+ - patch
12
+ - minor
13
+ - major
14
+
15
+ permissions: {}
16
+
17
+ jobs:
18
+ release:
19
+ permissions:
20
+ id-token: write # required for npm provenance via OIDC
21
+ contents: write # required to push the release commit and the tag
22
+ uses: fastify/workflows/.github/workflows/reusable-release.yml@b1a11bce713bc857e52b2231fec3c89071ad3135
23
+ with:
24
+ semver: ${{ inputs.semver }}
package/README.md CHANGED
@@ -156,7 +156,7 @@ async function subsystem (fastify, opts) {
156
156
  ### Hooks and middleware
157
157
 
158
158
  Every registered middleware will be run during the `onRequest` hook phase, so the registration order is important.
159
- Take a look at the [Lifecycle](https://fastify.dev/docs/latest/Reference/Lifecycle) documentation page to understand better how every request is executed.
159
+ Take a look at the [Lifecycle](https://fastify.dev/docs/latest/Reference/Lifecycle/) documentation page to understand better how every request is executed.
160
160
 
161
161
  ```js
162
162
  const fastify = require('fastify')()
package/index.js CHANGED
@@ -82,7 +82,6 @@ function fastifyExpress (fastify, options, next) {
82
82
  req.raw.body = req.body
83
83
  }
84
84
  // backward compatibility for cookie-parser
85
- /* c8 ignore next 3 */
86
85
  if (req.cookies) {
87
86
  req.raw.cookies = req.cookies
88
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastify/express",
3
- "version": "4.0.7",
3
+ "version": "4.0.8",
4
4
  "description": "Express compatibility layer for Fastify",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -59,11 +59,11 @@
59
59
  }
60
60
  ],
61
61
  "devDependencies": {
62
- "@fastify/formbody": "^8.0.0",
62
+ "@fastify/formbody": "^9.0.0",
63
63
  "@types/express": "^5.0.0",
64
64
  "@types/node": "*",
65
65
  "body-parser": "^1.20.2",
66
- "c8": "^11.0.0",
66
+ "c8": "^12.0.0",
67
67
  "cors": "^2.8.5",
68
68
  "eslint": "^9.17.0",
69
69
  "fastify": "^5.0.0",
@@ -66,6 +66,28 @@ test('Should support connect style middlewares (async await after)', async t =>
66
66
  t.assert.deepStrictEqual(await result.json(), { hello: 'world' })
67
67
  })
68
68
 
69
+ test('Should expose Fastify cookies to Express middleware', async t => {
70
+ t.plan(2)
71
+ const fastify = Fastify()
72
+ t.after(() => fastify.close())
73
+
74
+ fastify.addHook('onRequest', (request, _reply, done) => {
75
+ request.cookies = { session: 'cookie-value' }
76
+ done()
77
+ })
78
+
79
+ await fastify.register(expressPlugin)
80
+ fastify.use((request, _response, next) => {
81
+ t.assert.deepStrictEqual(request.cookies, { session: 'cookie-value' })
82
+ next()
83
+ })
84
+
85
+ fastify.get('/', async () => ({ hello: 'world' }))
86
+
87
+ const response = await fastify.inject('/')
88
+ t.assert.strictEqual(response.statusCode, 200)
89
+ })
90
+
69
91
  test('Should support per path middlewares', async t => {
70
92
  t.plan(2)
71
93
  const fastify = Fastify()