@fastify/express 2.0.1 → 2.1.0

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.
@@ -13,7 +13,5 @@ on:
13
13
  jobs:
14
14
  test:
15
15
  uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
16
-
17
-
18
-
19
-
16
+ with:
17
+ license-check: true
package/README.md CHANGED
@@ -40,7 +40,7 @@ async function build () {
40
40
  }
41
41
 
42
42
  build()
43
- .then(fastify => fastify.listen(3000))
43
+ .then(fastify => fastify.listen({ port: 3000 }))
44
44
  .catch(console.log)
45
45
  ```
46
46
 
@@ -92,7 +92,7 @@ fastify.register(require('@fastify/express'))
92
92
  fastify.use(router)
93
93
  })
94
94
 
95
- fastify.listen(3000, console.log)
95
+ fastify.listen({ port: 3000 }, console.log)
96
96
  ```
97
97
 
98
98
  #### Testing Your App
@@ -221,7 +221,7 @@ Example application:
221
221
  ```js
222
222
  const Fastify = require('fastify')
223
223
  const Express = require('express')
224
- const expressPlugin = require('fastify-express')
224
+ const expressPlugin = require('@fastify/express')
225
225
  const bodyParser = require('body-parser')
226
226
 
227
227
  const fastify = Fastify()
@@ -239,21 +239,21 @@ fastify.post('/hello', (req, reply) => {
239
239
  })
240
240
  ```
241
241
 
242
- For this case, you need to remove `body-parser`, install `fastify-formbody` and change `fastify-express` options:
242
+ For this case, you need to remove `body-parser`, install `@fastify/formbody` and change `@fastify/express` options:
243
243
 
244
244
 
245
245
  ```js
246
246
  const Fastify = require('fastify')
247
247
  const Express = require('express')
248
- const expressPlugin = require('fastify-express')
249
- const fastifyFormBody = require('fastify-formbody')
248
+ const expressPlugin = require('@fastify/express')
249
+ const fastifyFormBody = require('@fastify/formbody')
250
250
 
251
251
  const fastify = Fastify()
252
252
  const express = Express()
253
253
 
254
254
  await fastify.register(fastifyFormBody)
255
255
  await fastify.register(expressPlugin, {
256
- // run express after `fastify-formbody` logic
256
+ // run express after `@fastify/formbody` logic
257
257
  expressHook: 'preHandler'
258
258
  })
259
259
 
package/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  const fp = require('fastify-plugin')
4
- const symbols = require('fastify/lib/symbols')
5
4
  const Express = require('express')
6
5
  const kMiddlewares = Symbol('fastify-express-middlewares')
7
6
 
@@ -22,7 +21,7 @@ function expressPlugin (fastify, options, next) {
22
21
 
23
22
  function use (path, fn) {
24
23
  if (typeof path === 'string') {
25
- const prefix = this[symbols.kRoutePrefix]
24
+ const prefix = this.prefix
26
25
  path = prefix + (path === '/' && prefix.length > 0 ? '' : path)
27
26
  }
28
27
  this[kMiddlewares].push([path, fn])
@@ -52,12 +51,10 @@ function expressPlugin (fastify, options, next) {
52
51
  req.raw.cookies = req.cookies
53
52
  }
54
53
 
55
- const originalProtocol = req.raw.protocol
56
54
  // Make it lazy as it does a bit of work
57
55
  Object.defineProperty(req.raw, 'protocol', {
58
56
  get () {
59
- // added in Fastify@3.5, so handle it missing
60
- return req.protocol || originalProtocol
57
+ return req.protocol
61
58
  }
62
59
  })
63
60
 
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@fastify/express",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "Express compatibility layer for Fastify",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
- "scripts": {
8
- "test": "standard && tap --no-coverage test/*.test.js && tsd"
9
- },
10
7
  "repository": {
11
8
  "type": "git",
12
9
  "url": "git+https://github.com/fastify/fastify-express.git"
@@ -31,23 +28,26 @@
31
28
  "cors": "^2.8.5",
32
29
  "fastify": "^4.0.0-rc.3",
33
30
  "@fastify/formbody": "^7.0.1",
34
- "helmet": "^5.0.0",
31
+ "helmet": "^6.0.0",
35
32
  "passport": "^0.6.0",
36
33
  "passport-http-bearer": "^1.0.1",
37
34
  "serve-static": "^1.14.1",
38
35
  "simple-get": "^4.0.0",
39
36
  "standard": "^17.0.0",
40
37
  "tap": "^16.0.0",
41
- "tsd": "^0.21.0"
38
+ "tsd": "^0.24.1"
42
39
  },
43
40
  "dependencies": {
44
41
  "express": "^4.17.1",
45
- "fastify-plugin": "^3.0.0"
42
+ "fastify-plugin": "^4.0.0"
46
43
  },
47
44
  "tsd": {
48
45
  "directory": "test/types"
49
46
  },
50
47
  "publishConfig": {
51
48
  "access": "public"
49
+ },
50
+ "scripts": {
51
+ "test": "standard && tap --no-coverage test/*.test.js && tsd"
52
52
  }
53
- }
53
+ }