fastify 4.22.2 → 4.23.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 (95) hide show
  1. package/README.md +30 -33
  2. package/build/build-error-serializer.js +2 -2
  3. package/build/build-validation.js +2 -2
  4. package/build/sync-version.js +2 -2
  5. package/docs/Guides/Database.md +1 -1
  6. package/docs/Guides/Delay-Accepting-Requests.md +2 -2
  7. package/docs/Guides/Ecosystem.md +3 -1
  8. package/docs/Guides/Getting-Started.md +5 -4
  9. package/docs/Guides/Migration-Guide-V4.md +18 -15
  10. package/docs/Reference/ContentTypeParser.md +0 -1
  11. package/docs/Reference/HTTP2.md +4 -4
  12. package/docs/Reference/Hooks.md +30 -1
  13. package/docs/Reference/Middleware.md +1 -1
  14. package/docs/Reference/Principles.md +1 -1
  15. package/docs/Reference/Reply.md +7 -7
  16. package/docs/Reference/Request.md +11 -7
  17. package/docs/Reference/Server.md +2 -2
  18. package/examples/asyncawait.js +3 -1
  19. package/examples/benchmark/parser.js +1 -1
  20. package/examples/hooks.js +3 -0
  21. package/examples/http2.js +5 -3
  22. package/examples/https.js +5 -3
  23. package/examples/parser.js +4 -2
  24. package/examples/shared-schema.js +3 -1
  25. package/examples/simple-stream.js +4 -2
  26. package/examples/simple.js +3 -1
  27. package/examples/typescript-server.ts +1 -0
  28. package/examples/use-plugin.js +3 -1
  29. package/fastify.d.ts +2 -2
  30. package/fastify.js +5 -7
  31. package/lib/contentTypeParser.js +4 -4
  32. package/lib/error-handler.js +1 -1
  33. package/lib/hooks.js +55 -0
  34. package/lib/pluginUtils.js +1 -1
  35. package/lib/reply.js +1 -1
  36. package/lib/request.js +15 -0
  37. package/lib/server.js +26 -10
  38. package/lib/warnings.js +8 -0
  39. package/package.json +15 -5
  40. package/test/404s.test.js +1 -1
  41. package/test/als.test.js +1 -1
  42. package/test/async-await.test.js +1 -1
  43. package/test/bodyLimit.test.js +1 -1
  44. package/test/build/error-serializer.test.js +2 -2
  45. package/test/build/version.test.js +2 -2
  46. package/test/bundler/webpack/webpack.config.js +1 -1
  47. package/test/client-timeout.test.js +1 -1
  48. package/test/close.test.js +2 -2
  49. package/test/connectionTimeout.test.js +1 -1
  50. package/test/custom-http-server.test.js +2 -2
  51. package/test/custom-parser.0.test.js +1 -1
  52. package/test/custom-querystring-parser.test.js +1 -1
  53. package/test/diagnostics-channel.test.js +3 -3
  54. package/test/fastify-instance.test.js +1 -1
  55. package/test/genReqId.test.js +1 -1
  56. package/test/helper.js +2 -2
  57. package/test/hooks-async.test.js +2 -2
  58. package/test/hooks.on-listen.test.js +1090 -0
  59. package/test/hooks.on-ready.test.js +1 -1
  60. package/test/hooks.test.js +4 -4
  61. package/test/http2/closing.test.js +3 -3
  62. package/test/http2/missing-http2-module.test.js +1 -1
  63. package/test/https/custom-https-server.test.js +2 -2
  64. package/test/inject.test.js +3 -3
  65. package/test/internals/contentTypeParser.test.js +1 -1
  66. package/test/internals/errors.test.js +2 -2
  67. package/test/internals/initialConfig.test.js +1 -1
  68. package/test/internals/logger.test.js +1 -1
  69. package/test/internals/reply.test.js +7 -7
  70. package/test/internals/reqIdGenFactory.test.js +6 -2
  71. package/test/internals/server.test.js +4 -4
  72. package/test/keepAliveTimeout.test.js +1 -1
  73. package/test/listen.deprecated.test.js +1 -1
  74. package/test/listen.test.js +19 -5
  75. package/test/maxRequestsPerSocket.test.js +1 -1
  76. package/test/plugin.name.display.js +1 -1
  77. package/test/reply-error.test.js +4 -4
  78. package/test/reply-trailers.test.js +3 -3
  79. package/test/request-error.test.js +1 -1
  80. package/test/request.deprecated.test.js +38 -0
  81. package/test/requestTimeout.test.js +1 -1
  82. package/test/route-hooks.test.js +1 -1
  83. package/test/route.test.js +1 -1
  84. package/test/router-options.test.js +5 -6
  85. package/test/serial/logger.0.test.js +2 -2
  86. package/test/serial/logger.1.test.js +5 -5
  87. package/test/skip-reply-send.test.js +1 -1
  88. package/test/stream.test.js +20 -20
  89. package/test/trust-proxy.test.js +1 -1
  90. package/test/types/hooks.test-d.ts +11 -0
  91. package/test/unsupported-httpversion.test.js +1 -1
  92. package/test/upgrade.test.js +3 -3
  93. package/test/versioned-routes.test.js +1 -1
  94. package/types/hooks.d.ts +45 -12
  95. package/types/instance.d.ts +11 -1
package/fastify.d.ts CHANGED
@@ -12,7 +12,7 @@ import { Chain as LightMyRequestChain, InjectOptions, Response as LightMyRequest
12
12
  import { FastifyBodyParser, FastifyContentTypeParser, AddContentTypeParser, hasContentTypeParser, getDefaultJsonParser, ProtoAction, ConstructorAction } from './types/content-type-parser'
13
13
  import { FastifyContext, FastifyContextConfig } from './types/context'
14
14
  import { FastifyErrorCodes } from './types/errors'
15
- import { DoneFuncWithErrOrRes, HookHandlerDoneFunction, RequestPayload, onCloseAsyncHookHandler, onCloseHookHandler, onErrorAsyncHookHandler, onErrorHookHandler, onReadyAsyncHookHandler, onReadyHookHandler, onRegisterHookHandler, onRequestAsyncHookHandler, onRequestHookHandler, onResponseAsyncHookHandler, onResponseHookHandler, onRouteHookHandler, onSendAsyncHookHandler, onSendHookHandler, onTimeoutAsyncHookHandler, onTimeoutHookHandler, preHandlerAsyncHookHandler, preHandlerHookHandler, preParsingAsyncHookHandler, preParsingHookHandler, preSerializationAsyncHookHandler, preSerializationHookHandler, preValidationAsyncHookHandler, preValidationHookHandler, onRequestAbortHookHandler, onRequestAbortAsyncHookHandler } from './types/hooks'
15
+ import { DoneFuncWithErrOrRes, HookHandlerDoneFunction, RequestPayload, onCloseAsyncHookHandler, onCloseHookHandler, onErrorAsyncHookHandler, onErrorHookHandler, onReadyAsyncHookHandler, onReadyHookHandler, onListenAsyncHookHandler, onListenHookHandler, onRegisterHookHandler, onRequestAsyncHookHandler, onRequestHookHandler, onResponseAsyncHookHandler, onResponseHookHandler, onRouteHookHandler, onSendAsyncHookHandler, onSendHookHandler, onTimeoutAsyncHookHandler, onTimeoutHookHandler, preHandlerAsyncHookHandler, preHandlerHookHandler, preParsingAsyncHookHandler, preParsingHookHandler, preSerializationAsyncHookHandler, preSerializationHookHandler, preValidationAsyncHookHandler, preValidationHookHandler, onRequestAbortHookHandler, onRequestAbortAsyncHookHandler } from './types/hooks'
16
16
  import { FastifyListenOptions, FastifyInstance, PrintRoutesOptions } from './types/instance'
17
17
  import { FastifyBaseLogger, FastifyLoggerInstance, FastifyLoggerOptions, PinoLoggerOptions, FastifyLogFn, LogLevel, Bindings, ChildLoggerOptions } from './types/logger'
18
18
  import { FastifyPluginCallback, FastifyPluginAsync, FastifyPluginOptions, FastifyPlugin } from './types/plugin'
@@ -182,7 +182,7 @@ declare namespace fastify {
182
182
  FastifyError, // '@fastify/error'
183
183
  FastifySchema, FastifySchemaCompiler, // './types/schema'
184
184
  HTTPMethods, RawServerBase, RawRequestDefaultExpression, RawReplyDefaultExpression, RawServerDefault, ContextConfigDefault, RequestBodyDefault, RequestQuerystringDefault, RequestParamsDefault, RequestHeadersDefault, // './types/utils'
185
- DoneFuncWithErrOrRes, HookHandlerDoneFunction, RequestPayload, onCloseAsyncHookHandler, onCloseHookHandler, onErrorAsyncHookHandler, onErrorHookHandler, onReadyAsyncHookHandler, onReadyHookHandler, onRegisterHookHandler, onRequestAsyncHookHandler, onRequestHookHandler, onResponseAsyncHookHandler, onResponseHookHandler, onRouteHookHandler, onSendAsyncHookHandler, onSendHookHandler, onTimeoutAsyncHookHandler, onTimeoutHookHandler, preHandlerAsyncHookHandler, preHandlerHookHandler, preParsingAsyncHookHandler, preParsingHookHandler, preSerializationAsyncHookHandler, preSerializationHookHandler, preValidationAsyncHookHandler, preValidationHookHandler, onRequestAbortHookHandler, onRequestAbortAsyncHookHandler, // './types/hooks'
185
+ DoneFuncWithErrOrRes, HookHandlerDoneFunction, RequestPayload, onCloseAsyncHookHandler, onCloseHookHandler, onErrorAsyncHookHandler, onErrorHookHandler, onReadyAsyncHookHandler, onReadyHookHandler, onListenAsyncHookHandler, onListenHookHandler, onRegisterHookHandler, onRequestAsyncHookHandler, onRequestHookHandler, onResponseAsyncHookHandler, onResponseHookHandler, onRouteHookHandler, onSendAsyncHookHandler, onSendHookHandler, onTimeoutAsyncHookHandler, onTimeoutHookHandler, preHandlerAsyncHookHandler, preHandlerHookHandler, preParsingAsyncHookHandler, preParsingHookHandler, preSerializationAsyncHookHandler, preSerializationHookHandler, preValidationAsyncHookHandler, preValidationHookHandler, onRequestAbortHookHandler, onRequestAbortAsyncHookHandler, // './types/hooks'
186
186
  FastifyServerFactory, FastifyServerFactoryHandler, // './types/serverFactory'
187
187
  FastifyTypeProvider, FastifyTypeProviderDefault, // './types/type-provider'
188
188
  FastifyErrorCodes, // './types/errors'
package/fastify.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict'
2
2
 
3
- const VERSION = '4.22.2'
3
+ const VERSION = '4.23.0'
4
4
 
5
5
  const Avvio = require('avvio')
6
- const http = require('http')
6
+ const http = require('node:http')
7
7
  let lightMyRequest
8
8
 
9
9
  const {
@@ -496,7 +496,7 @@ function fastify (options) {
496
496
  server.on('clientError', options.clientErrorHandler.bind(fastify))
497
497
 
498
498
  try {
499
- const dc = require('diagnostics_channel')
499
+ const dc = require('node:diagnostics_channel')
500
500
  const initChannel = dc.channel('fastify.initialization')
501
501
  if (initChannel.hasSubscribers) {
502
502
  initChannel.publish({ fastify })
@@ -620,7 +620,7 @@ function fastify (options) {
620
620
  if (fn.constructor.name === 'AsyncFunction' && fn.length === 4) {
621
621
  throw new errorCodes.FST_ERR_HOOK_INVALID_ASYNC_HANDLER()
622
622
  }
623
- } else if (name === 'onReady') {
623
+ } else if (name === 'onReady' || name === 'onListen') {
624
624
  if (fn.constructor.name === 'AsyncFunction' && fn.length !== 0) {
625
625
  throw new errorCodes.FST_ERR_HOOK_INVALID_ASYNC_HANDLER()
626
626
  }
@@ -636,9 +636,7 @@ function fastify (options) {
636
636
 
637
637
  if (name === 'onClose') {
638
638
  this.onClose(fn)
639
- } else if (name === 'onReady') {
640
- this[kHooks].add(name, fn)
641
- } else if (name === 'onRoute') {
639
+ } else if (name === 'onReady' || name === 'onListen' || name === 'onRoute') {
642
640
  this[kHooks].add(name, fn)
643
641
  } else {
644
642
  this.after((err, done) => {
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const { AsyncResource } = require('async_hooks')
4
- const lru = require('tiny-lru').lru
3
+ const { AsyncResource } = require('node:async_hooks')
4
+ const { Fifo } = require('toad-cache')
5
5
  const { safeParse: safeParseContentType, defaultContentType } = require('fast-content-type-parse')
6
6
  const secureJson = require('secure-json-parse')
7
7
  const {
@@ -36,7 +36,7 @@ function ContentTypeParser (bodyLimit, onProtoPoisoning, onConstructorPoisoning)
36
36
  this.customParsers.set('text/plain', new Parser(true, false, bodyLimit, defaultPlainTextParser))
37
37
  this.parserList = [new ParserListItem('application/json'), new ParserListItem('text/plain')]
38
38
  this.parserRegExpList = []
39
- this.cache = lru(100)
39
+ this.cache = new Fifo(100)
40
40
  }
41
41
 
42
42
  ContentTypeParser.prototype.add = function (contentType, opts, parserFn) {
@@ -136,7 +136,7 @@ ContentTypeParser.prototype.removeAll = function () {
136
136
  this.customParsers = new Map()
137
137
  this.parserRegExpList = []
138
138
  this.parserList = []
139
- this.cache = lru(100)
139
+ this.cache = new Fifo(100)
140
140
  }
141
141
 
142
142
  ContentTypeParser.prototype.remove = function (contentType) {
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const statusCodes = require('http').STATUS_CODES
3
+ const statusCodes = require('node:http').STATUS_CODES
4
4
  const wrapThenable = require('./wrapThenable')
5
5
  const {
6
6
  kReplyHeaders,
package/lib/hooks.js CHANGED
@@ -4,6 +4,7 @@ const applicationHooks = [
4
4
  'onRoute',
5
5
  'onRegister',
6
6
  'onReady',
7
+ 'onListen',
7
8
  'preClose',
8
9
  'onClose'
9
10
  ]
@@ -48,6 +49,7 @@ function Hooks () {
48
49
  this.onRoute = []
49
50
  this.onRegister = []
50
51
  this.onReady = []
52
+ this.onListen = []
51
53
  this.onTimeout = []
52
54
  this.onRequestAbort = []
53
55
  this.preClose = []
@@ -83,6 +85,7 @@ function buildHooks (h) {
83
85
  hooks.onTimeout = h.onTimeout.slice()
84
86
  hooks.onRequestAbort = h.onRequestAbort.slice()
85
87
  hooks.onReady = []
88
+ hooks.onListen = []
86
89
  hooks.preClose = []
87
90
  return hooks
88
91
  }
@@ -174,6 +177,57 @@ function hookRunnerApplication (hookName, boot, server, cb) {
174
177
  }
175
178
  }
176
179
 
180
+ function onListenHookRunner (server) {
181
+ const hooks = server[kHooks].onListen
182
+ const hooksLen = hooks.length
183
+
184
+ if (hooksLen === 0) {
185
+ return
186
+ }
187
+
188
+ let i = 0
189
+ let c = 0
190
+
191
+ next()
192
+
193
+ function next (err) {
194
+ err && server.log.error(err)
195
+
196
+ if (
197
+ i === hooksLen
198
+ ) {
199
+ if (c < server[kChildren].length) {
200
+ const child = server[kChildren][c++]
201
+ onListenHookRunner(child)
202
+ }
203
+ return
204
+ }
205
+
206
+ wrap(hooks[i++], server, next)
207
+ }
208
+
209
+ async function wrap (fn, server, done) {
210
+ if (fn.length === 1) {
211
+ try {
212
+ fn.call(server, done)
213
+ } catch (e) {
214
+ done(e)
215
+ }
216
+ return
217
+ }
218
+ try {
219
+ const ret = fn.call(server)
220
+ if (ret && typeof ret.then === 'function') {
221
+ ret.then(done, done)
222
+ return
223
+ }
224
+ done()
225
+ } catch (error) {
226
+ done(error)
227
+ }
228
+ }
229
+ }
230
+
177
231
  function hookRunnerGenerator (iterator) {
178
232
  return function hookRunner (functions, request, reply, cb) {
179
233
  let i = 0
@@ -366,6 +420,7 @@ module.exports = {
366
420
  onRequestAbortHookRunner,
367
421
  hookIterator,
368
422
  hookRunnerApplication,
423
+ onListenHookRunner,
369
424
  preHandlerHookRunner,
370
425
  preValidationHookRunner,
371
426
  onRequestHookRunner,
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const semver = require('semver')
4
- const assert = require('assert')
4
+ const assert = require('node:assert')
5
5
  const kRegisteredPlugins = Symbol.for('registered-plugin')
6
6
  const {
7
7
  kTestInternals
package/lib/reply.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const eos = require('stream').finished
3
+ const eos = require('node:stream').finished
4
4
 
5
5
  const {
6
6
  kFourOhFourContext,
package/lib/request.js CHANGED
@@ -172,6 +172,7 @@ Object.defineProperties(Request.prototype, {
172
172
  },
173
173
  routerPath: {
174
174
  get () {
175
+ warning.emit('FSTDEP017')
175
176
  return this[kRouteContext].config?.url
176
177
  }
177
178
  },
@@ -189,23 +190,37 @@ Object.defineProperties(Request.prototype, {
189
190
  logLevel: context.logLevel,
190
191
  exposeHeadRoute: context.exposeHeadRoute,
191
192
  prefixTrailingSlash: context.prefixTrailingSlash,
193
+ handler: context.handler,
192
194
  version
193
195
  }
196
+
197
+ Object.defineProperties(options, {
198
+ config: {
199
+ get: () => context.config
200
+ },
201
+ schema: {
202
+ get: () => context.schema
203
+ }
204
+ })
205
+
194
206
  return Object.freeze(options)
195
207
  }
196
208
  },
197
209
  routerMethod: {
198
210
  get () {
211
+ warning.emit('FSTDEP018')
199
212
  return this[kRouteContext].config?.method
200
213
  }
201
214
  },
202
215
  routeConfig: {
203
216
  get () {
217
+ warning.emit('FSTDEP016')
204
218
  return this[kRouteContext][kPublicRouteContext]?.config
205
219
  }
206
220
  },
207
221
  routeSchema: {
208
222
  get () {
223
+ warning.emit('FSTDEP015')
209
224
  return this[kRouteContext][kPublicRouteContext].schema
210
225
  }
211
226
  },
package/lib/server.js CHANGED
@@ -1,11 +1,12 @@
1
1
  'use strict'
2
2
 
3
- const http = require('http')
4
- const https = require('https')
5
- const dns = require('dns')
3
+ const http = require('node:http')
4
+ const https = require('node:https')
5
+ const dns = require('node:dns')
6
6
 
7
7
  const warnings = require('./warnings')
8
8
  const { kState, kOptions, kServerBindings } = require('./symbols')
9
+ const { onListenHookRunner } = require('./hooks')
9
10
  const {
10
11
  FST_ERR_HTTP2_INVALID_VERSION,
11
12
  FST_ERR_REOPENED_CLOSE_SERVER,
@@ -85,8 +86,20 @@ function createServer (options, httpHandler) {
85
86
  multipleBindings.call(this, server, httpHandler, options, listenOptions, () => {
86
87
  this[kState].listening = true
87
88
  cb(null, address)
89
+ onListenHookRunner(this)
88
90
  })
89
91
  }
92
+ } else {
93
+ listenOptions.cb = (err, address) => {
94
+ // the server did not start
95
+ if (err) {
96
+ cb(err, address)
97
+ return
98
+ }
99
+ this[kState].listening = true
100
+ cb(null, address)
101
+ onListenHookRunner(this)
102
+ }
90
103
  }
91
104
 
92
105
  // https://github.com/nodejs/node/issues/9390
@@ -97,17 +110,20 @@ function createServer (options, httpHandler) {
97
110
  if (cb === undefined) {
98
111
  const listening = listenPromise.call(this, server, listenOptions)
99
112
  /* istanbul ignore else */
100
- if (host === 'localhost') {
101
- return listening.then(address => {
102
- return new Promise((resolve, reject) => {
113
+ return listening.then(address => {
114
+ return new Promise((resolve, reject) => {
115
+ if (host === 'localhost') {
103
116
  multipleBindings.call(this, server, httpHandler, options, listenOptions, () => {
104
117
  this[kState].listening = true
105
118
  resolve(address)
119
+ onListenHookRunner(this)
106
120
  })
107
- })
121
+ } else {
122
+ resolve(address)
123
+ onListenHookRunner(this)
124
+ }
108
125
  })
109
- }
110
- return listening
126
+ })
111
127
  }
112
128
 
113
129
  this.ready(listenCallback.call(this, server, listenOptions))
@@ -410,7 +426,7 @@ function logServerAddress (server, listenTextResolver) {
410
426
 
411
427
  function http2 () {
412
428
  try {
413
- return require('http2')
429
+ return require('node:http2')
414
430
  } catch (err) {
415
431
  throw new FST_ERR_HTTP2_INVALID_VERSION()
416
432
  }
package/lib/warnings.js CHANGED
@@ -27,6 +27,14 @@ warning.create('FastifyDeprecation', 'FSTDEP013', 'Direct return of "trailers" f
27
27
 
28
28
  warning.create('FastifyDeprecation', 'FSTDEP014', 'You are trying to set/access the default route. This property is deprecated. Please, use setNotFoundHandler if you want to custom a 404 handler or the wildcard (*) to match all routes.')
29
29
 
30
+ warning.create('FastifyDeprecation', 'FSTDEP015', 'You are accessing the deprecated "request.routeSchema" property. Use "request.routeOptions.schema" instead. Property "req.routeSchema" will be removed in `fastify@5`.')
31
+
32
+ warning.create('FastifyDeprecation', 'FSTDEP016', 'You are accessing the deprecated "request.routeConfig" property. Use "request.routeOptions.config" instead. Property "req.routeConfig" will be removed in `fastify@5`.')
33
+
34
+ warning.create('FastifyDeprecation', 'FSTDEP017', 'You are accessing the deprecated "request.routerPath" property. Use "request.routeOptions.config.url" instead. Property "req.routerPath" will be removed in `fastify@5`.')
35
+
36
+ warning.create('FastifyDeprecation', 'FSTDEP018', 'You are accessing the deprecated "request.routerMethod" property. Use "request.routeOptions.config.method" instead. Property "req.routerMethod" will be removed in `fastify@5`.')
37
+
30
38
  warning.create('FastifyWarning', 'FSTWRN001', 'The %s schema for %s: %s is missing. This may indicate the schema is not well specified.', { unlimited: true })
31
39
 
32
40
  module.exports = warning
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify",
3
- "version": "4.22.2",
3
+ "version": "4.23.0",
4
4
  "description": "Fast and low overhead web framework, for Node.js",
5
5
  "main": "fastify.js",
6
6
  "type": "commonjs",
@@ -28,7 +28,8 @@
28
28
  "test:watch": "npm run unit -- -w --no-coverage-report -R terse",
29
29
  "unit": "c8 tap",
30
30
  "unit:junit": "tap-mocha-reporter xunit < out.tap > test/junit-testresults.xml",
31
- "unit:report": "tap --cov --coverage-report=html --coverage-report=cobertura | tee out.tap"
31
+ "unit:report": "tap --cov --coverage-report=html --coverage-report=cobertura | tee out.tap",
32
+ "citgm": "tap"
32
33
  },
33
34
  "repository": {
34
35
  "type": "git",
@@ -125,13 +126,22 @@
125
126
  "name": "Carlos Fuentes",
126
127
  "email": "me@metcoder.dev",
127
128
  "url": "https://metcoder.dev"
129
+ },
130
+ {
131
+ "name": "Gürgün Dayıoğlu",
132
+ "email": "gurgun.dayioglu@icloud.com",
133
+ "url": "https://heyhey.to/G"
134
+ },
135
+ {
136
+ "name": "Aras Abbasi",
137
+ "email": "aras.abbasi@gmail.com"
128
138
  }
129
139
  ],
130
140
  "license": "MIT",
131
141
  "bugs": {
132
142
  "url": "https://github.com/fastify/fastify/issues"
133
143
  },
134
- "homepage": "https://www.fastify.io/",
144
+ "homepage": "https://www.fastify.dev/",
135
145
  "devDependencies": {
136
146
  "@fastify/pre-commit": "^2.0.2",
137
147
  "@sinclair/typebox": "^0.31.1",
@@ -171,7 +181,7 @@
171
181
  "split2": "^4.2.0",
172
182
  "standard": "^17.0.0",
173
183
  "tap": "^16.3.4",
174
- "tsd": "^0.28.1",
184
+ "tsd": "^0.29.0",
175
185
  "typescript": "^5.0.4",
176
186
  "undici": "^5.22.0",
177
187
  "vary": "^1.1.2",
@@ -193,7 +203,7 @@
193
203
  "rfdc": "^1.3.0",
194
204
  "secure-json-parse": "^2.5.0",
195
205
  "semver": "^7.5.0",
196
- "tiny-lru": "^11.0.1"
206
+ "toad-cache": "^3.2.0"
197
207
  },
198
208
  "standard": {
199
209
  "ignore": [
package/test/404s.test.js CHANGED
@@ -1031,7 +1031,7 @@ test('setNotFoundHandler should not suppress duplicated routes checking', t => {
1031
1031
  test('log debug for 404', t => {
1032
1032
  t.plan(1)
1033
1033
 
1034
- const Writable = require('stream').Writable
1034
+ const Writable = require('node:stream').Writable
1035
1035
 
1036
1036
  const logStream = new Writable()
1037
1037
  logStream.logs = []
package/test/als.test.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { AsyncLocalStorage } = require('async_hooks')
3
+ const { AsyncLocalStorage } = require('node:async_hooks')
4
4
  const t = require('tap')
5
5
  const Fastify = require('..')
6
6
  const sget = require('simple-get').concat
@@ -6,7 +6,7 @@ const sget = require('simple-get').concat
6
6
  const Fastify = require('..')
7
7
  const split = require('split2')
8
8
  const pino = require('pino')
9
- const statusCodes = require('http').STATUS_CODES
9
+ const statusCodes = require('node:http').STATUS_CODES
10
10
  const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
11
11
 
12
12
  const opts = {
@@ -2,7 +2,7 @@
2
2
 
3
3
  const Fastify = require('..')
4
4
  const sget = require('simple-get').concat
5
- const zlib = require('zlib')
5
+ const zlib = require('node:zlib')
6
6
  const t = require('tap')
7
7
  const test = t.test
8
8
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  const t = require('tap')
4
4
  const test = t.test
5
- const fs = require('fs')
6
- const path = require('path')
5
+ const fs = require('node:fs')
6
+ const path = require('node:path')
7
7
 
8
8
  const { code } = require('../../build/build-error-serializer')
9
9
 
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const fs = require('fs')
4
- const path = require('path')
3
+ const fs = require('node:fs')
4
+ const path = require('node:path')
5
5
  const t = require('tap')
6
6
  const test = t.test
7
7
  const fastify = require('../../fastify')()
@@ -1,4 +1,4 @@
1
- const path = require('path')
1
+ const path = require('node:path')
2
2
 
3
3
  module.exports = {
4
4
  entry: { success: './src/index.js', failPlugin: './src/fail-plugin-version.js' },
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { test } = require('tap')
4
4
  const fastify = require('..')({ requestTimeout: 5, http: { connectionsCheckingInterval: 1000 } })
5
- const { connect } = require('net')
5
+ const { connect } = require('node:net')
6
6
 
7
7
  test('requestTimeout should return 408', t => {
8
8
  t.plan(1)
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const net = require('net')
4
- const http = require('http')
3
+ const net = require('node:net')
4
+ const http = require('node:http')
5
5
  const { test } = require('tap')
6
6
  const Fastify = require('..')
7
7
  const { Client } = require('undici')
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const Fastify = require('..')
4
- const http = require('http')
4
+ const http = require('node:http')
5
5
  const t = require('tap')
6
6
  const test = t.test
7
7
 
@@ -3,10 +3,10 @@
3
3
  const t = require('tap')
4
4
  const test = t.test
5
5
  const Fastify = require('..')
6
- const http = require('http')
6
+ const http = require('node:http')
7
7
  const { FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE } = require('../lib/errors')
8
8
  const sget = require('simple-get').concat
9
- const dns = require('dns').promises
9
+ const dns = require('node:dns').promises
10
10
 
11
11
  test('Should support a custom http server', async t => {
12
12
  const localAddresses = await dns.lookup('localhost', { all: true })
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const fs = require('fs')
3
+ const fs = require('node:fs')
4
4
  const t = require('tap')
5
5
  const test = t.test
6
6
  const sget = require('simple-get').concat
@@ -2,7 +2,7 @@
2
2
 
3
3
  const t = require('tap')
4
4
  const test = t.test
5
- const querystring = require('querystring')
5
+ const querystring = require('node:querystring')
6
6
  const sget = require('simple-get').concat
7
7
  const Fastify = require('..')
8
8
 
@@ -24,7 +24,7 @@ test('diagnostics_channel when present and subscribers', t => {
24
24
  }
25
25
 
26
26
  const fastify = proxyquire('../fastify', {
27
- diagnostics_channel: dc
27
+ 'node:diagnostics_channel': dc
28
28
  })()
29
29
  t.equal(fastifyInHook, fastify)
30
30
  })
@@ -46,7 +46,7 @@ test('diagnostics_channel when present and no subscribers', t => {
46
46
  }
47
47
 
48
48
  proxyquire('../fastify', {
49
- diagnostics_channel: dc
49
+ 'node:diagnostics_channel': dc
50
50
  })()
51
51
  })
52
52
 
@@ -55,7 +55,7 @@ test('diagnostics_channel when not present', t => {
55
55
 
56
56
  t.doesNotThrow(() => {
57
57
  proxyquire('../fastify', {
58
- diagnostics_channel: null
58
+ 'node:diagnostics_channel': null
59
59
  })()
60
60
  })
61
61
  })
@@ -3,7 +3,7 @@
3
3
  const t = require('tap')
4
4
  const test = t.test
5
5
  const Fastify = require('..')
6
- const os = require('os')
6
+ const os = require('node:os')
7
7
 
8
8
  const {
9
9
  kOptions,
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { Readable } = require('stream')
3
+ const { Readable } = require('node:stream')
4
4
  const { test } = require('tap')
5
5
  const Fastify = require('..')
6
6
 
package/test/helper.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  const sget = require('simple-get').concat
4
- const dns = require('dns').promises
5
- const stream = require('stream')
4
+ const dns = require('node:dns').promises
5
+ const stream = require('node:stream')
6
6
  const symbols = require('../lib/symbols')
7
7
 
8
8
  /**
@@ -1,11 +1,11 @@
1
1
  'use strict'
2
2
 
3
- const { Readable } = require('stream')
3
+ const { Readable } = require('node:stream')
4
4
  const t = require('tap')
5
5
  const test = t.test
6
6
  const sget = require('simple-get').concat
7
7
  const Fastify = require('../fastify')
8
- const fs = require('fs')
8
+ const fs = require('node:fs')
9
9
  const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
10
10
 
11
11
  process.removeAllListeners('warning')