fastify 5.1.0 → 5.2.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.
Files changed (111) hide show
  1. package/README.md +12 -7
  2. package/docs/Guides/Database.md +15 -15
  3. package/docs/Guides/Detecting-When-Clients-Abort.md +28 -28
  4. package/docs/Guides/Ecosystem.md +13 -7
  5. package/docs/Guides/Index.md +1 -1
  6. package/docs/Guides/Migration-Guide-V4.md +11 -11
  7. package/docs/Guides/Migration-Guide-V5.md +5 -5
  8. package/docs/Guides/Plugins-Guide.md +1 -1
  9. package/docs/Guides/Prototype-Poisoning.md +3 -3
  10. package/docs/Guides/Recommendations.md +9 -9
  11. package/docs/Guides/Serverless.md +5 -5
  12. package/docs/Guides/Testing.md +8 -8
  13. package/docs/Guides/Write-Plugin.md +1 -1
  14. package/docs/Guides/Write-Type-Provider.md +3 -3
  15. package/docs/Reference/Decorators.md +2 -2
  16. package/docs/Reference/Errors.md +2 -2
  17. package/docs/Reference/Hooks.md +7 -7
  18. package/docs/Reference/LTS.md +8 -0
  19. package/docs/Reference/Logging.md +5 -4
  20. package/docs/Reference/Reply.md +54 -53
  21. package/docs/Reference/Request.md +49 -43
  22. package/docs/Reference/Routes.md +7 -7
  23. package/docs/Reference/Server.md +31 -27
  24. package/docs/Reference/TypeScript.md +9 -9
  25. package/docs/Reference/Validation-and-Serialization.md +5 -5
  26. package/examples/typescript-server.ts +1 -1
  27. package/fastify.d.ts +4 -4
  28. package/fastify.js +1 -1
  29. package/lib/error-handler.js +9 -9
  30. package/lib/errors.js +1 -1
  31. package/lib/hooks.js +4 -1
  32. package/lib/request.js +11 -10
  33. package/package.json +3 -4
  34. package/test/{allowUnsafeRegex.test.js → allow-unsafe-regex.test.js} +4 -4
  35. package/test/async-dispose.test.js +0 -1
  36. package/test/async_hooks.test.js +4 -4
  37. package/test/buffer.test.js +4 -4
  38. package/test/build-certificate.js +1 -1
  39. package/test/bundler/README.md +5 -5
  40. package/test/case-insensitive.test.js +10 -10
  41. package/test/check.test.js +2 -3
  42. package/test/{childLoggerFactory.test.js → child-logger-factory.test.js} +1 -1
  43. package/test/client-timeout.test.js +1 -1
  44. package/test/close-pipelining.test.js +0 -1
  45. package/test/conditional-pino.test.js +3 -3
  46. package/test/content-length.test.js +53 -68
  47. package/test/content-parser.test.js +178 -167
  48. package/test/content-type.test.js +8 -9
  49. package/test/context-config.test.js +44 -54
  50. package/test/custom-parser.5.test.js +32 -32
  51. package/test/encapsulated-child-logger-factory.test.js +8 -8
  52. package/test/encapsulated-error-handler.test.js +20 -20
  53. package/test/fastify-instance.test.js +33 -34
  54. package/test/{findRoute.test.js → find-route.test.js} +11 -10
  55. package/test/fluent-schema.test.js +33 -36
  56. package/test/handler-context.test.js +11 -11
  57. package/test/has-route.test.js +12 -15
  58. package/test/header-overflow.test.js +13 -12
  59. package/test/hooks.on-ready.test.js +2 -2
  60. package/test/hooks.test.js +19 -19
  61. package/test/http-methods/head.test.js +0 -3
  62. package/test/imports.test.js +2 -2
  63. package/test/internals/errors.test.js +1 -1
  64. package/test/listen.5.test.js +9 -9
  65. package/test/{maxRequestsPerSocket.test.js → max-requests-per-socket.test.js} +30 -30
  66. package/test/middleware.test.js +4 -5
  67. package/test/noop-set.test.js +1 -1
  68. package/test/post-empty-body.test.js +18 -11
  69. package/test/pretty-print.test.js +59 -49
  70. package/test/proto-poisoning.test.js +42 -37
  71. package/test/reply-code.test.js +34 -32
  72. package/test/{reply-earlyHints.test.js → reply-early-hints.test.js} +21 -19
  73. package/test/request-header-host.test.js +154 -12
  74. package/test/request-id.test.js +31 -25
  75. package/test/{requestTimeout.test.js → request-timeout.test.js} +11 -11
  76. package/test/route.3.test.js +3 -2
  77. package/test/route.8.test.js +20 -20
  78. package/test/router-options.test.js +80 -77
  79. package/test/schema-examples.test.js +72 -38
  80. package/test/server.test.js +12 -12
  81. package/test/set-error-handler.test.js +2 -3
  82. package/test/stream-serializers.test.js +10 -7
  83. package/test/sync-routes.test.js +18 -18
  84. package/test/trust-proxy.test.js +51 -45
  85. package/test/type-provider.test.js +8 -6
  86. package/test/types/content-type-parser.test-d.ts +1 -1
  87. package/test/types/fastify.test-d.ts +4 -4
  88. package/test/types/instance.test-d.ts +3 -1
  89. package/test/types/logger.test-d.ts +2 -2
  90. package/test/types/plugin.test-d.ts +2 -2
  91. package/test/types/register.test-d.ts +2 -2
  92. package/test/types/reply.test-d.ts +1 -1
  93. package/test/types/route.test-d.ts +1 -1
  94. package/test/types/serverFactory.test-d.ts +1 -1
  95. package/test/types/type-provider.test-d.ts +1 -1
  96. package/test/url-rewriting.test.js +35 -38
  97. package/test/{useSemicolonDelimiter.test.js → use-semicolon-delimiter.test.js} +30 -30
  98. package/test/validation-error-handling.test.js +259 -285
  99. package/types/hooks.d.ts +1 -1
  100. package/types/instance.d.ts +9 -2
  101. package/types/reply.d.ts +1 -1
  102. package/types/request.d.ts +0 -4
  103. package/types/serverFactory.d.ts +3 -3
  104. package/types/utils.d.ts +3 -3
  105. /package/test/{connectionTimeout.test.js → connection-timeout.test.js} +0 -0
  106. /package/test/internals/{contentTypeParser.test.js → content-type-parser.test.js} +0 -0
  107. /package/test/internals/{handleRequest.test.js → handle-request.test.js} +0 -0
  108. /package/test/internals/{hookRunner.test.js → hook-runner.test.js} +0 -0
  109. /package/test/internals/{initialConfig.test.js → initial-config.test.js} +0 -0
  110. /package/test/internals/{reqIdGenFactory.test.js → req-id-gen-factory.test.js} +0 -0
  111. /package/test/{wrapThenable.test.js → wrap-thenable.test.js} +0 -0
@@ -85,7 +85,7 @@ test('abort signal', async t => {
85
85
  await t.test('listen should not start server', (t, end) => {
86
86
  t.plan(2)
87
87
  function onClose (instance, done) {
88
- t.assert.equal(instance, fastify)
88
+ t.assert.strictEqual(instance, fastify)
89
89
  done()
90
90
  end()
91
91
  }
@@ -103,7 +103,7 @@ test('abort signal', async t => {
103
103
  await t.test('listen should not start server if already aborted', (t, end) => {
104
104
  t.plan(2)
105
105
  function onClose (instance, done) {
106
- t.assert.equal(instance, fastify)
106
+ t.assert.strictEqual(instance, fastify)
107
107
  done()
108
108
  end()
109
109
  }
@@ -134,21 +134,19 @@ test('abort signal', async t => {
134
134
  })
135
135
  })
136
136
 
137
- test('#5180 - preClose should be called before closing secondary server', (t, end) => {
137
+ test('#5180 - preClose should be called before closing secondary server', async (t) => {
138
138
  t.plan(2)
139
139
  const fastify = Fastify({ forceCloseConnections: true })
140
140
  let flag = false
141
141
  t.after(() => fastify.close())
142
142
 
143
- fastify.addHook('preClose', async () => {
143
+ fastify.addHook('preClose', () => {
144
144
  flag = true
145
145
  })
146
146
 
147
147
  fastify.get('/', async (req, reply) => {
148
- await new Promise((resolve) => {
149
- setTimeout(() => resolve(1), 1000)
150
- })
151
-
148
+ // request will be pending for 1 second to simulate a slow request
149
+ await new Promise((resolve) => { setTimeout(resolve, 1000) })
152
150
  return { hello: 'world' }
153
151
  })
154
152
 
@@ -177,12 +175,14 @@ test('#5180 - preClose should be called before closing secondary server', (t, en
177
175
  () => { t.assert.fail('Request should not succeed') },
178
176
  () => {
179
177
  t.assert.ok(flag)
180
- end()
181
178
  }
182
179
  )
183
180
 
184
- setTimeout(() => {
185
- fastify.close()
186
- }, 250)
181
+ // Close the server while the slow request is pending
182
+ setTimeout(fastify.close, 250)
187
183
  })
184
+
185
+ // Wait 1000ms to ensure that the test is finished and async operations are
186
+ // completed
187
+ await new Promise((resolve) => { setTimeout(resolve, 1000) })
188
188
  })
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const t = require('tap')
4
- const test = t.test
3
+ const { test } = require('node:test')
5
4
  const Fastify = require('..')
6
5
  const { FST_ERR_ERROR_HANDLER_NOT_FN } = require('../lib/errors')
7
6
 
@@ -9,5 +8,5 @@ test('setErrorHandler should throw an error if the handler is not a function', t
9
8
  t.plan(1)
10
9
  const fastify = Fastify()
11
10
 
12
- t.throws(() => fastify.setErrorHandler('not a function'), new FST_ERR_ERROR_HANDLER_NOT_FN())
11
+ t.assert.throws(() => fastify.setErrorHandler('not a function'), new FST_ERR_ERROR_HANDLER_NOT_FN())
13
12
  })
@@ -1,18 +1,19 @@
1
1
  'use strict'
2
2
 
3
- const t = require('tap')
4
- const test = t.test
3
+ const { test } = require('node:test')
5
4
  const Fastify = require('..')
6
5
  const Reply = require('../lib/reply')
7
6
 
8
- test('should serialize reply when response stream is ended', t => {
9
- t.plan(3)
7
+ test('should serialize reply when response stream is ended', (t, done) => {
8
+ t.plan(5)
9
+
10
10
  const stream = require('node:stream')
11
11
  const fastify = Fastify({
12
12
  logger: {
13
13
  serializers: {
14
14
  res (reply) {
15
- t.type(reply, Reply)
15
+ t.assert.strictEqual(reply instanceof Reply, true)
16
+ t.assert.ok('passed')
16
17
  return reply
17
18
  }
18
19
  }
@@ -27,11 +28,13 @@ test('should serialize reply when response stream is ended', t => {
27
28
  reply.raw.end(Buffer.from('hello\n'))
28
29
  })
29
30
 
31
+ t.after(() => fastify.close())
32
+
30
33
  fastify.inject({
31
34
  url: '/error',
32
35
  method: 'GET'
33
36
  }, (err) => {
34
- t.error(err)
35
- fastify.close()
37
+ t.assert.ifError(err)
38
+ done()
36
39
  })
37
40
  })
@@ -1,32 +1,32 @@
1
1
  'use strict'
2
2
 
3
- const { test } = require('tap')
3
+ const { test } = require('node:test')
4
4
  const Fastify = require('..')
5
5
 
6
6
  test('sync route', async t => {
7
- const app = Fastify()
8
- t.teardown(app.close.bind(app))
9
- app.get('/', () => 'hello world')
10
- const res = await app.inject('/')
11
- t.equal(res.statusCode, 200)
12
- t.equal(res.body, 'hello world')
7
+ const fastify = Fastify()
8
+ t.after(() => fastify.close())
9
+ fastify.get('/', () => 'hello world')
10
+ const res = await fastify.inject('/')
11
+ t.assert.strictEqual(res.statusCode, 200)
12
+ t.assert.strictEqual(res.body, 'hello world')
13
13
  })
14
14
 
15
15
  test('sync route return null', async t => {
16
- const app = Fastify()
17
- t.teardown(app.close.bind(app))
18
- app.get('/', () => null)
19
- const res = await app.inject('/')
20
- t.equal(res.statusCode, 200)
21
- t.equal(res.body, 'null')
16
+ const fastify = Fastify()
17
+ t.after(() => fastify.close())
18
+ fastify.get('/', () => null)
19
+ const res = await fastify.inject('/')
20
+ t.assert.strictEqual(res.statusCode, 200)
21
+ t.assert.strictEqual(res.body, 'null')
22
22
  })
23
23
 
24
24
  test('sync route, error', async t => {
25
- const app = Fastify()
26
- t.teardown(app.close.bind(app))
27
- app.get('/', () => {
25
+ const fastify = Fastify()
26
+ t.after(() => fastify.close())
27
+ fastify.get('/', () => {
28
28
  throw new Error('kaboom')
29
29
  })
30
- const res = await app.inject('/')
31
- t.equal(res.statusCode, 500)
30
+ const res = await fastify.inject('/')
31
+ t.assert.strictEqual(res.statusCode, 500)
32
32
  })
@@ -1,12 +1,13 @@
1
1
  'use strict'
2
2
 
3
- const t = require('tap')
4
- const { test, before } = t
3
+ const { test, before } = require('node:test')
5
4
  const sget = require('simple-get').concat
6
5
  const fastify = require('..')
7
6
  const helper = require('./helper')
8
7
 
9
- const sgetForwardedRequest = (app, forHeader, path, protoHeader) => {
8
+ const noop = () => {}
9
+
10
+ const sgetForwardedRequest = (app, forHeader, path, protoHeader, testCaseDone) => {
10
11
  const headers = {
11
12
  'X-Forwarded-For': forHeader,
12
13
  'X-Forwarded-Host': 'example.com'
@@ -18,30 +19,30 @@ const sgetForwardedRequest = (app, forHeader, path, protoHeader) => {
18
19
  method: 'GET',
19
20
  headers,
20
21
  url: 'http://localhost:' + app.server.address().port + path
21
- }, () => {})
22
+ }, testCaseDone || noop)
22
23
  }
23
24
 
24
25
  const testRequestValues = (t, req, options) => {
25
26
  if (options.ip) {
26
- t.ok(req.ip, 'ip is defined')
27
- t.equal(req.ip, options.ip, 'gets ip from x-forwarded-for')
27
+ t.assert.ok(req.ip, 'ip is defined')
28
+ t.assert.strictEqual(req.ip, options.ip, 'gets ip from x-forwarded-for')
28
29
  }
29
30
  if (options.host) {
30
- t.ok(req.host, 'host is defined')
31
- t.equal(req.host, options.host, 'gets host from x-forwarded-host')
32
- t.ok(req.hostname)
33
- t.equal(req.hostname, options.host, 'gets hostname from x-forwarded-host')
31
+ t.assert.ok(req.host, 'host is defined')
32
+ t.assert.strictEqual(req.host, options.host, 'gets host from x-forwarded-host')
33
+ t.assert.ok(req.hostname)
34
+ t.assert.strictEqual(req.hostname, options.host, 'gets hostname from x-forwarded-host')
34
35
  }
35
36
  if (options.ips) {
36
- t.same(req.ips, options.ips, 'gets ips from x-forwarded-for')
37
+ t.assert.deepStrictEqual(req.ips, options.ips, 'gets ips from x-forwarded-for')
37
38
  }
38
39
  if (options.protocol) {
39
- t.ok(req.protocol, 'protocol is defined')
40
- t.equal(req.protocol, options.protocol, 'gets protocol from x-forwarded-proto')
40
+ t.assert.ok(req.protocol, 'protocol is defined')
41
+ t.assert.strictEqual(req.protocol, options.protocol, 'gets protocol from x-forwarded-proto')
41
42
  }
42
43
  if (options.port) {
43
- t.ok(req.port, 'port is defined')
44
- t.equal(req.port, options.port, 'port is taken from x-forwarded-for or host')
44
+ t.assert.ok(req.port, 'port is defined')
45
+ t.assert.strictEqual(req.port, options.port, 'port is taken from x-forwarded-for or host')
45
46
  }
46
47
  }
47
48
 
@@ -50,11 +51,13 @@ before(async function () {
50
51
  [localhost] = await helper.getLoopbackHost()
51
52
  })
52
53
 
53
- test('trust proxy, not add properties to node req', (t) => {
54
+ test('trust proxy, not add properties to node req', (t, done) => {
54
55
  t.plan(14)
55
56
  const app = fastify({
56
57
  trustProxy: true
57
58
  })
59
+ t.after(() => app.close())
60
+
58
61
  app.get('/trustproxy', function (req, reply) {
59
62
  testRequestValues(t, req, { ip: '1.1.1.1', host: 'example.com', port: app.server.address().port })
60
63
  reply.code(200).send({ ip: req.ip, host: req.host })
@@ -65,17 +68,23 @@ test('trust proxy, not add properties to node req', (t) => {
65
68
  reply.code(200).send({ ip: req.ip, host: req.host })
66
69
  })
67
70
 
68
- t.teardown(app.close.bind(app))
69
-
70
71
  app.listen({ port: 0 }, (err) => {
71
72
  app.server.unref()
72
- t.error(err)
73
- sgetForwardedRequest(app, '1.1.1.1', '/trustproxy')
74
- sgetForwardedRequest(app, '2.2.2.2, 1.1.1.1', '/trustproxychain')
73
+ t.assert.ifError(err)
74
+
75
+ sgetForwardedRequest(app, '1.1.1.1', '/trustproxy', undefined, completed)
76
+ sgetForwardedRequest(app, '2.2.2.2, 1.1.1.1', '/trustproxychain', undefined, completed)
77
+
78
+ let pending = 2
79
+ function completed () {
80
+ if (--pending === 0) {
81
+ done()
82
+ }
83
+ }
75
84
  })
76
85
  })
77
86
 
78
- test('trust proxy chain', (t) => {
87
+ test('trust proxy chain', (t, done) => {
79
88
  t.plan(9)
80
89
  const app = fastify({
81
90
  trustProxy: [localhost, '192.168.1.1']
@@ -86,16 +95,15 @@ test('trust proxy chain', (t) => {
86
95
  reply.code(200).send({ ip: req.ip, host: req.host })
87
96
  })
88
97
 
89
- t.teardown(app.close.bind(app))
90
-
91
98
  app.listen({ port: 0 }, (err) => {
92
99
  app.server.unref()
93
- t.error(err)
94
- sgetForwardedRequest(app, '192.168.1.1, 1.1.1.1', '/trustproxychain')
100
+ t.assert.ifError(err)
101
+ t.after(() => app.close())
102
+ sgetForwardedRequest(app, '192.168.1.1, 1.1.1.1', '/trustproxychain', undefined, done)
95
103
  })
96
104
  })
97
105
 
98
- test('trust proxy function', (t) => {
106
+ test('trust proxy function', (t, done) => {
99
107
  t.plan(9)
100
108
  const app = fastify({
101
109
  trustProxy: (address) => address === localhost
@@ -105,16 +113,15 @@ test('trust proxy function', (t) => {
105
113
  reply.code(200).send({ ip: req.ip, host: req.host })
106
114
  })
107
115
 
108
- t.teardown(app.close.bind(app))
109
-
110
116
  app.listen({ port: 0 }, (err) => {
111
117
  app.server.unref()
112
- t.error(err)
113
- sgetForwardedRequest(app, '1.1.1.1', '/trustproxyfunc')
118
+ t.assert.ifError(err)
119
+ t.after(() => app.close())
120
+ sgetForwardedRequest(app, '1.1.1.1', '/trustproxyfunc', undefined, done)
114
121
  })
115
122
  })
116
123
 
117
- test('trust proxy number', (t) => {
124
+ test('trust proxy number', (t, done) => {
118
125
  t.plan(10)
119
126
  const app = fastify({
120
127
  trustProxy: 1
@@ -124,16 +131,15 @@ test('trust proxy number', (t) => {
124
131
  reply.code(200).send({ ip: req.ip, host: req.host })
125
132
  })
126
133
 
127
- t.teardown(app.close.bind(app))
128
-
129
134
  app.listen({ port: 0 }, (err) => {
130
135
  app.server.unref()
131
- t.error(err)
132
- sgetForwardedRequest(app, '2.2.2.2, 1.1.1.1', '/trustproxynumber')
136
+ t.assert.ifError(err)
137
+ t.after(() => app.close())
138
+ sgetForwardedRequest(app, '2.2.2.2, 1.1.1.1', '/trustproxynumber', undefined, done)
133
139
  })
134
140
  })
135
141
 
136
- test('trust proxy IP addresses', (t) => {
142
+ test('trust proxy IP addresses', (t, done) => {
137
143
  t.plan(10)
138
144
  const app = fastify({
139
145
  trustProxy: `${localhost}, 2.2.2.2`
@@ -143,16 +149,15 @@ test('trust proxy IP addresses', (t) => {
143
149
  reply.code(200).send({ ip: req.ip, host: req.host })
144
150
  })
145
151
 
146
- t.teardown(app.close.bind(app))
147
-
148
152
  app.listen({ port: 0 }, (err) => {
149
153
  app.server.unref()
150
- t.error(err)
151
- sgetForwardedRequest(app, '3.3.3.3, 2.2.2.2, 1.1.1.1', '/trustproxyipaddrs')
154
+ t.assert.ifError(err)
155
+ t.after(() => app.close())
156
+ sgetForwardedRequest(app, '3.3.3.3, 2.2.2.2, 1.1.1.1', '/trustproxyipaddrs', undefined, done)
152
157
  })
153
158
  })
154
159
 
155
- test('trust proxy protocol', (t) => {
160
+ test('trust proxy protocol', (t, done) => {
156
161
  t.plan(31)
157
162
  const app = fastify({
158
163
  trustProxy: true
@@ -170,13 +175,14 @@ test('trust proxy protocol', (t) => {
170
175
  reply.code(200).send({ ip: req.ip, host: req.host })
171
176
  })
172
177
 
173
- t.teardown(app.close.bind(app))
178
+ t.after(() => app.close())
174
179
 
175
180
  app.listen({ port: 0 }, (err) => {
176
181
  app.server.unref()
177
- t.error(err)
182
+ t.assert.ifError(err)
178
183
  sgetForwardedRequest(app, '1.1.1.1', '/trustproxyprotocol', 'lorem')
179
184
  sgetForwardedRequest(app, '1.1.1.1', '/trustproxynoprotocol')
180
- sgetForwardedRequest(app, '1.1.1.1', '/trustproxyprotocols', 'ipsum, dolor')
185
+ // Allow for sgetForwardedRequest requests above to finish
186
+ setTimeout(() => sgetForwardedRequest(app, '1.1.1.1', '/trustproxyprotocols', 'ipsum, dolor', done))
181
187
  })
182
188
  })
@@ -1,20 +1,22 @@
1
1
  'use strict'
2
2
 
3
- const { test } = require('tap')
3
+ const { test } = require('node:test')
4
4
  const Fastify = require('..')
5
5
 
6
- test('Should export withTypeProvider function', t => {
6
+ test('Should export withTypeProvider function', (t, done) => {
7
7
  t.plan(1)
8
8
  try {
9
9
  Fastify().withTypeProvider()
10
- t.pass()
10
+ t.assert.ok('pass')
11
+ done()
11
12
  } catch (e) {
12
- t.fail()
13
+ t.assert.fail(e)
13
14
  }
14
15
  })
15
16
 
16
- test('Should return same instance', t => {
17
+ test('Should return same instance', (t, done) => {
17
18
  t.plan(1)
18
19
  const fastify = Fastify()
19
- t.equal(fastify, fastify.withTypeProvider())
20
+ t.assert.strictEqual(fastify, fastify.withTypeProvider())
21
+ done()
20
22
  })
@@ -1,6 +1,6 @@
1
1
  import fastify, { FastifyBodyParser } from '../../fastify'
2
2
  import { expectError, expectType } from 'tsd'
3
- import { IncomingMessage } from 'http'
3
+ import { IncomingMessage } from 'node:http'
4
4
  import { FastifyRequest } from '../../types/request'
5
5
 
6
6
  expectType<void>(fastify().addContentTypeParser('contentType', function (request, payload, done) {
@@ -1,8 +1,8 @@
1
1
  import { ErrorObject as AjvErrorObject } from 'ajv'
2
- import * as http from 'http'
3
- import * as http2 from 'http2'
4
- import * as https from 'https'
5
- import { Socket } from 'net'
2
+ import * as http from 'node:http'
3
+ import * as http2 from 'node:http2'
4
+ import * as https from 'node:https'
5
+ import { Socket } from 'node:net'
6
6
  import { expectAssignable, expectError, expectNotAssignable, expectType } from 'tsd'
7
7
  import fastify, {
8
8
  ConnectionError,
@@ -13,7 +13,7 @@ import { HookHandlerDoneFunction } from '../../types/hooks'
13
13
  import { FastifyReply } from '../../types/reply'
14
14
  import { FastifyRequest } from '../../types/request'
15
15
  import { FastifySchemaControllerOptions, FastifySchemaCompiler, FastifySerializerCompiler } from '../../types/schema'
16
- import { AddressInfo } from 'net'
16
+ import { AddressInfo } from 'node:net'
17
17
  import { Bindings, ChildLoggerOptions } from '../../types/logger'
18
18
 
19
19
  const server = fastify()
@@ -193,6 +193,8 @@ function invalidSchemaErrorFormatter (err: Error) {
193
193
  }
194
194
  expectError(server.setSchemaErrorFormatter(invalidSchemaErrorFormatter))
195
195
 
196
+ expectType<FastifyInstance>(server.addHttpMethod('SEARCH', { hasBody: true }))
197
+
196
198
  // test listen opts objects
197
199
  expectAssignable<PromiseLike<string>>(server.listen())
198
200
  expectAssignable<PromiseLike<string>>(server.listen({ port: 3000 }))
@@ -7,8 +7,8 @@ import fastify, {
7
7
  FastifyReply,
8
8
  FastifyBaseLogger
9
9
  } from '../../fastify'
10
- import { Server, IncomingMessage, ServerResponse } from 'http'
11
- import * as fs from 'fs'
10
+ import { Server, IncomingMessage, ServerResponse } from 'node:http'
11
+ import * as fs from 'node:fs'
12
12
  import P from 'pino'
13
13
  import { ResSerializerReply } from '../../types/logger'
14
14
 
@@ -1,6 +1,6 @@
1
1
  import fastify, { FastifyInstance, FastifyPluginOptions, SafePromiseLike } from '../../fastify'
2
- import * as http from 'http'
3
- import * as https from 'https'
2
+ import * as http from 'node:http'
3
+ import * as https from 'node:https'
4
4
  import { expectType, expectError, expectAssignable } from 'tsd'
5
5
  import { FastifyPluginCallback, FastifyPluginAsync } from '../../types/plugin'
6
6
  import { FastifyError } from '@fastify/error'
@@ -1,6 +1,6 @@
1
1
  import { expectAssignable, expectError, expectType } from 'tsd'
2
- import { IncomingMessage, Server, ServerResponse } from 'http'
3
- import { Http2Server, Http2ServerRequest, Http2ServerResponse } from 'http2'
2
+ import { IncomingMessage, Server, ServerResponse } from 'node:http'
3
+ import { Http2Server, Http2ServerRequest, Http2ServerResponse } from 'node:http2'
4
4
  import fastify, { FastifyInstance, FastifyError, FastifyLoggerInstance, FastifyPluginAsync, FastifyPluginCallback, FastifyPluginOptions, RawServerDefault } from '../../fastify'
5
5
 
6
6
  const testPluginCallback: FastifyPluginCallback = function (instance, opts, done) { }
@@ -1,4 +1,4 @@
1
- import { Buffer } from 'buffer'
1
+ import { Buffer } from 'node:buffer'
2
2
  import { expectAssignable, expectError, expectType } from 'tsd'
3
3
  import fastify, { FastifyContextConfig, FastifyReply, FastifyRequest, FastifySchema, FastifyTypeProviderDefault, RawRequestDefaultExpression, RouteHandler, RouteHandlerMethod } from '../../fastify'
4
4
  import { FastifyInstance } from '../../types/instance'
@@ -1,5 +1,5 @@
1
1
  import { FastifyError } from '@fastify/error'
2
- import * as http from 'http'
2
+ import * as http from 'node:http'
3
3
  import { expectAssignable, expectError, expectType } from 'tsd'
4
4
  import fastify, { FastifyInstance, FastifyReply, FastifyRequest, RouteHandlerMethod } from '../../fastify'
5
5
  import { RequestPayload } from '../../types/hooks'
@@ -1,5 +1,5 @@
1
1
  import fastify, { FastifyServerFactory } from '../../fastify'
2
- import * as http from 'http'
2
+ import * as http from 'node:http'
3
3
  import { expectType } from 'tsd'
4
4
 
5
5
  // Custom Server
@@ -8,7 +8,7 @@ import fastify, {
8
8
  SafePromiseLike
9
9
  } from '../../fastify'
10
10
  import { expectAssignable, expectError, expectType } from 'tsd'
11
- import { IncomingHttpHeaders } from 'http'
11
+ import { IncomingHttpHeaders } from 'node:http'
12
12
  import { Type, TSchema, Static } from '@sinclair/typebox'
13
13
  import { FromSchema, JSONSchema } from 'json-schema-to-ts'
14
14