fastify 4.0.3 → 4.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.
package/.eslintrc CHANGED
@@ -1,3 +1,4 @@
1
1
  {
2
+ "root": true,
2
3
  "extends": "standard"
3
4
  }
@@ -37,7 +37,7 @@ fastify.get('/user/:id', function(req, reply) {
37
37
  )
38
38
  })
39
39
 
40
- fastify.listen(3000, err => {
40
+ fastify.listen({ port: 3000 }, err => {
41
41
  if (err) throw err
42
42
  console.log(`server listening on ${fastify.server.address().port}`)
43
43
  })
@@ -64,7 +64,7 @@ fastify.get('/user/:id', function (req, reply) {
64
64
  )
65
65
  })
66
66
 
67
- fastify.listen(3000, err => {
67
+ fastify.listen({ port: 3000 }, err => {
68
68
  if (err) throw err
69
69
  console.log(`server listening on ${fastify.server.address().port}`)
70
70
  })
@@ -98,7 +98,7 @@ fastify.post('/foo', function (req, reply) {
98
98
  })
99
99
  })
100
100
 
101
- fastify.listen(3000, err => {
101
+ fastify.listen({ port: 3000 }, err => {
102
102
  if (err) throw err
103
103
  console.log(`server listening on ${fastify.server.address().port}`)
104
104
  })
@@ -145,7 +145,7 @@ fastify.get('/user/:id', function (req, reply) {
145
145
  })
146
146
  })
147
147
 
148
- fastify.listen(3000, err => {
148
+ fastify.listen({ port: 3000 }, err => {
149
149
  if (err) throw err
150
150
  })
151
151
  ```
@@ -172,7 +172,7 @@ fastify.post('/foo', async function (req, reply) {
172
172
  return { status: 'ok' }
173
173
  })
174
174
 
175
- fastify.listen(3000, err => {
175
+ fastify.listen({ port: 3000 }, err => {
176
176
  if (err) throw err
177
177
  console.log(`server listening on ${fastify.server.address().port}`)
178
178
  })
@@ -16,6 +16,23 @@ have decided not to support the use of middlewares. Both
16
16
  [`@fastify/express`](https://github.com/fastify/fastify-express) will still be
17
17
  there and maintained. Use Fastify's [hooks](../Reference/Hooks.md) instead.
18
18
 
19
+ ### `reply.res` moved to `reply.raw`
20
+
21
+ If you previously used the `reply.res` attribute to access the underlying Request
22
+ object you'll instead need to depend on `reply.raw`.
23
+
24
+ ### Need to `return reply` to signal a "fork" of the promise chain
25
+
26
+ In some situations, like when a response is sent asynchronously or when you're
27
+ just not explicitly returning a response, you'll need to return the `reply`
28
+ argument from your router handler.
29
+
30
+ ### `exposeHeadRoutes` true by default
31
+
32
+ Starting from v4, all the `GET` routes will create a sibling `HEAD` route.
33
+ You can revert this behaviour by setting the server's option `exposeHeadRoutes`
34
+ to `false`.
35
+
19
36
  ## Non Breaking Changes
20
37
 
21
38
  ### Change of schema for multiple types
@@ -1278,7 +1278,7 @@ const fastify = Fastify({
1278
1278
  */
1279
1279
  bucket: function factory (parentSchemas) {
1280
1280
  return {
1281
- addSchema (inputSchema) {
1281
+ add (inputSchema) {
1282
1282
  // This function must store the schema added by the user.
1283
1283
  // This function is invoked when `fastify.addSchema()` is called.
1284
1284
  },
@@ -30,11 +30,11 @@ $ npm i @fastify/type-provider-json-schema-to-ts
30
30
  ```
31
31
 
32
32
  ```typescript
33
- import { JsonSchemaToTsTypeProvider } from '@fastify/type-provider-json-schema-to-ts'
33
+ import { JsonSchemaToTsProvider } from '@fastify/type-provider-json-schema-to-ts'
34
34
 
35
35
  import fastify from 'fastify'
36
36
 
37
- const server = fastify().withTypeProvider<JsonSchemaToTsTypeProvider>()
37
+ const server = fastify().withTypeProvider<JsonSchemaToTsProvider>()
38
38
 
39
39
  server.get('/route', {
40
40
  schema: {
package/fastify.d.ts CHANGED
@@ -146,7 +146,7 @@ export type FastifyServerOptions<
146
146
  },
147
147
  schemaController?: {
148
148
  bucket?: (parentSchemas?: unknown) => {
149
- addSchema(schema: unknown): FastifyInstance;
149
+ add(schema: unknown): FastifyInstance;
150
150
  getSchema(schemaId: string): unknown;
151
151
  getSchemas(): Record<string, unknown>;
152
152
  };
package/fastify.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const VERSION = '4.0.3'
3
+ const VERSION = '4.1.0'
4
4
 
5
5
  const Avvio = require('avvio')
6
6
  const http = require('http')
@@ -237,35 +237,35 @@ function fastify (options) {
237
237
  getDefaultRoute: router.getDefaultRoute.bind(router),
238
238
  setDefaultRoute: router.setDefaultRoute.bind(router),
239
239
  // routes shorthand methods
240
- delete: function _delete (url, opts, handler) {
241
- return router.prepareRoute.call(this, 'DELETE', url, opts, handler)
240
+ delete: function _delete (url, options, handler) {
241
+ return router.prepareRoute.call(this, { method: 'DELETE', url, options, handler })
242
242
  },
243
- get: function _get (url, opts, handler) {
244
- return router.prepareRoute.call(this, 'GET', url, opts, handler)
243
+ get: function _get (url, options, handler) {
244
+ return router.prepareRoute.call(this, { method: 'GET', url, options, handler })
245
245
  },
246
- head: function _head (url, opts, handler) {
247
- return router.prepareRoute.call(this, 'HEAD', url, opts, handler)
246
+ head: function _head (url, options, handler) {
247
+ return router.prepareRoute.call(this, { method: 'HEAD', url, options, handler })
248
248
  },
249
- patch: function _patch (url, opts, handler) {
250
- return router.prepareRoute.call(this, 'PATCH', url, opts, handler)
249
+ patch: function _patch (url, options, handler) {
250
+ return router.prepareRoute.call(this, { method: 'PATCH', url, options, handler })
251
251
  },
252
- post: function _post (url, opts, handler) {
253
- return router.prepareRoute.call(this, 'POST', url, opts, handler)
252
+ post: function _post (url, options, handler) {
253
+ return router.prepareRoute.call(this, { method: 'POST', url, options, handler })
254
254
  },
255
- put: function _put (url, opts, handler) {
256
- return router.prepareRoute.call(this, 'PUT', url, opts, handler)
255
+ put: function _put (url, options, handler) {
256
+ return router.prepareRoute.call(this, { method: 'PUT', url, options, handler })
257
257
  },
258
- options: function _options (url, opts, handler) {
259
- return router.prepareRoute.call(this, 'OPTIONS', url, opts, handler)
258
+ options: function _options (url, options, handler) {
259
+ return router.prepareRoute.call(this, { method: 'OPTIONS', url, options, handler })
260
260
  },
261
- all: function _all (url, opts, handler) {
262
- return router.prepareRoute.call(this, supportedMethods, url, opts, handler)
261
+ all: function _all (url, options, handler) {
262
+ return router.prepareRoute.call(this, { method: supportedMethods, url, options, handler })
263
263
  },
264
264
  // extended route
265
- route: function _route (opts) {
265
+ route: function _route (options) {
266
266
  // we need the fastify object that we are producing so we apply a lazy loading of the function,
267
267
  // otherwise we should bind it after the declaration
268
- return router.route.call(this, opts)
268
+ return router.route.call(this, { options })
269
269
  },
270
270
  // expose logger instance
271
271
  log: logger,
package/lib/reply.js CHANGED
@@ -331,10 +331,12 @@ Reply.prototype.redirect = function (code, url) {
331
331
  }
332
332
 
333
333
  this.header('location', url).code(code).send()
334
+ return this
334
335
  }
335
336
 
336
337
  Reply.prototype.callNotFound = function () {
337
338
  notFound(this)
339
+ return this
338
340
  }
339
341
 
340
342
  Reply.prototype.getResponseTime = function () {
package/lib/route.js CHANGED
@@ -113,7 +113,7 @@ function buildRouting (options) {
113
113
  }
114
114
 
115
115
  // Convert shorthand to extended route declaration
116
- function prepareRoute (method, url, options, handler) {
116
+ function prepareRoute ({ method, url, options, handler }) {
117
117
  if (typeof url !== 'string') {
118
118
  throw new FST_ERR_INVALID_URL(typeof url)
119
119
  }
@@ -140,11 +140,11 @@ function buildRouting (options) {
140
140
  handler: handler || (options && options.handler)
141
141
  })
142
142
 
143
- return route.call(this, options)
143
+ return route.call(this, { options })
144
144
  }
145
145
 
146
146
  // Route management
147
- function route (options) {
147
+ function route ({ options }) {
148
148
  // Since we are mutating/assigning only top level props, it is fine to have a shallow copy using the spread operator
149
149
  const opts = { ...options }
150
150
 
@@ -176,30 +176,30 @@ function buildRouting (options) {
176
176
  if (path === '/' && prefix.length > 0 && opts.method !== 'HEAD') {
177
177
  switch (opts.prefixTrailingSlash) {
178
178
  case 'slash':
179
- addNewRoute.call(this, path)
179
+ addNewRoute.call(this, { path })
180
180
  break
181
181
  case 'no-slash':
182
- addNewRoute.call(this, '')
182
+ addNewRoute.call(this, { path: '' })
183
183
  break
184
184
  case 'both':
185
185
  default:
186
- addNewRoute.call(this, '')
186
+ addNewRoute.call(this, { path: '' })
187
187
  // If ignoreTrailingSlash is set to true we need to add only the '' route to prevent adding an incomplete one.
188
188
  if (ignoreTrailingSlash !== true && (ignoreDuplicateSlashes !== true || !prefix.endsWith('/'))) {
189
- addNewRoute.call(this, path, true)
189
+ addNewRoute.call(this, { path, prefixing: true })
190
190
  }
191
191
  }
192
192
  } else if (path[0] === '/' && prefix.endsWith('/')) {
193
193
  // Ensure that '/prefix/' + '/route' gets registered as '/prefix/route'
194
- addNewRoute.call(this, path.slice(1))
194
+ addNewRoute.call(this, { path: path.slice(1) })
195
195
  } else {
196
- addNewRoute.call(this, path)
196
+ addNewRoute.call(this, { path })
197
197
  }
198
198
 
199
199
  // chainable api
200
200
  return this
201
201
 
202
- function addNewRoute (path, prefixing = false) {
202
+ function addNewRoute ({ path, prefixing = false }) {
203
203
  const url = prefix + path
204
204
 
205
205
  opts.url = url
@@ -326,7 +326,7 @@ function buildRouting (options) {
326
326
 
327
327
  if (shouldExposeHead && options.method === 'GET' && !headRouteExists) {
328
328
  const onSendHandlers = parseHeadOnSendHandlers(opts.onSend)
329
- prepareRoute.call(this, 'HEAD', path, { ...opts, onSend: onSendHandlers })
329
+ prepareRoute.call(this, { method: 'HEAD', url: path, options: { ...opts, onSend: onSendHandlers } })
330
330
  } else if (headRouteExists && exposeHeadRoute) {
331
331
  warning.emit('FSTDEP007')
332
332
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify",
3
- "version": "4.0.3",
3
+ "version": "4.1.0",
4
4
  "description": "Fast and low overhead web framework, for Node.js",
5
5
  "main": "fastify.js",
6
6
  "type": "commonjs",
@@ -128,7 +128,7 @@
128
128
  "@fastify/pre-commit": "^2.0.2",
129
129
  "@sinclair/typebox": "^0.23.5",
130
130
  "@sinonjs/fake-timers": "^9.1.2",
131
- "@types/node": "^17.0.38",
131
+ "@types/node": "^18.0.0",
132
132
  "@typescript-eslint/eslint-plugin": "^5.27.0",
133
133
  "@typescript-eslint/parser": "^5.27.0",
134
134
  "ajv": "^8.11.0",
package/test/404s.test.js CHANGED
@@ -1320,7 +1320,7 @@ test('preHandler option for setNotFoundHandler', t => {
1320
1320
 
1321
1321
  // https://github.com/fastify/fastify/issues/2229
1322
1322
  t.test('preHandler hook in setNotFoundHandler should be called when callNotFound', { timeout: 40000 }, t => {
1323
- t.plan(2)
1323
+ t.plan(3)
1324
1324
  const fastify = Fastify()
1325
1325
 
1326
1326
  fastify.setNotFoundHandler({
@@ -1333,7 +1333,7 @@ test('preHandler option for setNotFoundHandler', t => {
1333
1333
  })
1334
1334
 
1335
1335
  fastify.post('/', function (req, reply) {
1336
- reply.callNotFound()
1336
+ t.equal(reply.callNotFound(), reply)
1337
1337
  })
1338
1338
 
1339
1339
  fastify.inject({
@@ -7,6 +7,10 @@ const path = require('path')
7
7
 
8
8
  const { code } = require('../../build/build-error-serializer')
9
9
 
10
+ function unifyLineBreak (str) {
11
+ return str.toString().replace(/\r\n/g, '\n')
12
+ }
13
+
10
14
  test('check generated code syntax', async (t) => {
11
15
  t.plan(1)
12
16
 
@@ -24,5 +28,6 @@ test('ensure the current error serializer is latest', async (t) => {
24
28
 
25
29
  const current = await fs.promises.readFile(path.resolve('lib/error-serializer.js'))
26
30
 
27
- t.equal(current.toString(), code)
31
+ // line break should not be a problem depends on system
32
+ t.equal(unifyLineBreak(current), unifyLineBreak(code))
28
33
  })
@@ -233,6 +233,10 @@ test('within an instance', t => {
233
233
  reply.redirect('/')
234
234
  })
235
235
 
236
+ fastify.get('/redirect-async', async function (req, reply) {
237
+ return reply.redirect('/')
238
+ })
239
+
236
240
  fastify.get('/redirect-code', function (req, reply) {
237
241
  reply.redirect(301, '/')
238
242
  })
@@ -412,6 +416,14 @@ test('within an instance', t => {
412
416
  })
413
417
  })
414
418
 
419
+ test('redirect with async function to `/` - 10', t => {
420
+ t.plan(1)
421
+
422
+ http.get('http://localhost:' + fastify.server.address().port + '/redirect-async', function (response) {
423
+ t.equal(response.statusCode, 302)
424
+ })
425
+ })
426
+
415
427
  t.end()
416
428
  })
417
429
  })
@@ -770,7 +770,7 @@ test('request terminated should not crash fastify', t => {
770
770
 
771
771
  reply.send(stream)
772
772
 
773
- await new Promise((resolve) => { setTimeout(resolve, 6).unref() })
773
+ await new Promise((resolve) => { setTimeout(resolve, 100).unref() })
774
774
 
775
775
  stream.push('<h1>should disply on second stream</h1>')
776
776
  stream.push(null)
@@ -133,7 +133,7 @@ expectError(server.setErrorHandler(invalidErrorHandler))
133
133
  server.setSchemaController({
134
134
  bucket: (parentSchemas: unknown) => {
135
135
  return {
136
- addSchema (schema: unknown) {
136
+ add (schema: unknown) {
137
137
  expectType<unknown>(schema)
138
138
  expectType<FastifyInstance>(server.addSchema({ type: 'null' }))
139
139
  return server.addSchema({ type: 'null' })
@@ -1,7 +1,21 @@
1
1
  import { expectAssignable, expectError, expectType } from 'tsd'
2
- import fastify, { FastifyInstance, FastifyPluginAsync } from '../../fastify'
2
+ import { IncomingMessage, Server, ServerResponse } from 'http'
3
+ import { Http2Server, Http2ServerRequest, Http2ServerResponse } from 'http2'
4
+ import fastify, { FastifyInstance, FastifyError, FastifyLoggerInstance, FastifyPluginAsync, FastifyPluginCallback, FastifyPluginOptions, RawServerDefault } from '../../fastify'
3
5
 
4
- const testPluginOptsAsync: FastifyPluginAsync = async function (_instance, _opts) { }
6
+ const testPluginCallback: FastifyPluginCallback = function (instance, opts, done) { }
7
+ const testPluginAsync: FastifyPluginAsync = async function (instance, opts) { }
8
+
9
+ const testPluginOpts: FastifyPluginCallback = function (instance, opts, done) { }
10
+ const testPluginOptsAsync: FastifyPluginAsync = async function (instance, opts) { }
11
+
12
+ const testPluginOptsWithType = (instance: FastifyInstance, opts: FastifyPluginOptions, done: (error?: FastifyError) => void) => { }
13
+ const testPluginOptsWithTypeAsync = async (instance: FastifyInstance, opts: FastifyPluginOptions) => { }
14
+
15
+ interface TestOptions extends FastifyPluginOptions {
16
+ option1: string;
17
+ option2: boolean;
18
+ }
5
19
 
6
20
  // Type validation
7
21
  expectError(fastify().register(testPluginOptsAsync, { prefix: 1 }))
@@ -26,3 +40,64 @@ expectAssignable<FastifyInstance>(
26
40
  expectType<FastifyInstance>(instance)
27
41
  })
28
42
  )
43
+
44
+ // With Http2
45
+ const serverWithHttp2 = fastify({ http2: true })
46
+ type ServerWithHttp2 = FastifyInstance<Http2Server, Http2ServerRequest, Http2ServerResponse>
47
+ const testPluginWithHttp2: FastifyPluginCallback<TestOptions, Http2Server> = function (instance, opts, done) { }
48
+ const testPluginWithHttp2Async: FastifyPluginAsync<TestOptions, Http2Server> = async function (instance, opts) { }
49
+ const testPluginWithHttp2WithType = (instance: ServerWithHttp2, opts: FastifyPluginOptions, done: (error?: FastifyError) => void) => { }
50
+ const testPluginWithHttp2WithTypeAsync = async (instance: ServerWithHttp2, opts: FastifyPluginOptions) => { }
51
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(testPluginCallback))
52
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(testPluginAsync))
53
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(testPluginOpts))
54
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(testPluginOptsAsync))
55
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(testPluginOptsWithType))
56
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(testPluginOptsWithTypeAsync))
57
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(testPluginWithHttp2))
58
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(testPluginWithHttp2Async))
59
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(testPluginWithHttp2WithType))
60
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(testPluginWithHttp2WithTypeAsync))
61
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register((instance) => {
62
+ expectAssignable<FastifyInstance>(instance)
63
+ }))
64
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register((instance: ServerWithHttp2) => {
65
+ expectAssignable<ServerWithHttp2>(instance)
66
+ }))
67
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(async (instance) => {
68
+ expectAssignable<FastifyInstance>(instance)
69
+ }))
70
+ expectAssignable<ServerWithHttp2>(serverWithHttp2.register(async (instance: ServerWithHttp2) => {
71
+ expectAssignable<ServerWithHttp2>(instance)
72
+ }))
73
+
74
+ // With Type Provider
75
+ type TestTypeProvider = { input: 'test', output: 'test' }
76
+ const serverWithTypeProvider = fastify().withTypeProvider<TestTypeProvider>()
77
+ type ServerWithTypeProvider = FastifyInstance<Server, IncomingMessage, ServerResponse, FastifyLoggerInstance, TestTypeProvider>
78
+ const testPluginWithTypeProvider: FastifyPluginCallback<TestOptions, RawServerDefault, TestTypeProvider> = function (instance, opts, done) { }
79
+ const testPluginWithTypeProviderAsync: FastifyPluginAsync<TestOptions, RawServerDefault, TestTypeProvider> = async function (instance, opts) { }
80
+ const testPluginWithTypeProviderWithType = (instance: ServerWithTypeProvider, opts: FastifyPluginOptions, done: (error?: FastifyError) => void) => { }
81
+ const testPluginWithTypeProviderWithTypeAsync = async (instance: ServerWithTypeProvider, opts: FastifyPluginOptions) => { }
82
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(testPluginCallback))
83
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(testPluginAsync))
84
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(testPluginOpts))
85
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(testPluginOptsAsync))
86
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(testPluginOptsWithType))
87
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(testPluginOptsWithTypeAsync))
88
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(testPluginWithTypeProvider))
89
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(testPluginWithTypeProviderAsync))
90
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(testPluginWithTypeProviderWithType))
91
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(testPluginWithTypeProviderWithTypeAsync))
92
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register((instance) => {
93
+ expectAssignable<FastifyInstance>(instance)
94
+ }))
95
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register((instance: ServerWithTypeProvider) => {
96
+ expectAssignable<ServerWithTypeProvider>(instance)
97
+ }))
98
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(async (instance) => {
99
+ expectAssignable<FastifyInstance>(instance)
100
+ }))
101
+ expectAssignable<ServerWithTypeProvider>(serverWithTypeProvider.register(async (instance: ServerWithTypeProvider) => {
102
+ expectAssignable<ServerWithTypeProvider>(instance)
103
+ }))
@@ -1,6 +1,8 @@
1
1
  import { FastifyPluginOptions, FastifyPluginCallback, FastifyPluginAsync } from './plugin'
2
2
  import { LogLevel } from './logger'
3
3
  import { FastifyInstance } from './instance'
4
+ import { RawServerBase } from './utils'
5
+ import { FastifyTypeProvider, RawServerDefault } from '../fastify'
4
6
 
5
7
  export interface RegisterOptions {
6
8
  prefix?: string;
@@ -15,17 +17,17 @@ export type FastifyRegisterOptions<Options> = (RegisterOptions & Options) | ((in
15
17
  *
16
18
  * Function for adding a plugin to fastify. The options are inferred from the passed in FastifyPlugin parameter.
17
19
  */
18
- export interface FastifyRegister<T = void> {
19
- <Options extends FastifyPluginOptions>(
20
- plugin: FastifyPluginCallback<Options>,
20
+ export interface FastifyRegister<T = void, RawServer extends RawServerBase = RawServerDefault, TypeProviderDefault extends FastifyTypeProvider = FastifyTypeProvider> {
21
+ <Options extends FastifyPluginOptions, Server extends RawServerBase = RawServer, TypeProvider extends FastifyTypeProvider = TypeProviderDefault>(
22
+ plugin: FastifyPluginCallback<Options, Server, TypeProvider>,
21
23
  opts?: FastifyRegisterOptions<Options>
22
24
  ): T;
23
- <Options extends FastifyPluginOptions>(
24
- plugin: FastifyPluginAsync<Options>,
25
+ <Options extends FastifyPluginOptions, Server extends RawServerBase = RawServer, TypeProvider extends FastifyTypeProvider = TypeProviderDefault>(
26
+ plugin: FastifyPluginAsync<Options, Server, TypeProvider>,
25
27
  opts?: FastifyRegisterOptions<Options>
26
28
  ): T;
27
- <Options extends FastifyPluginOptions>(
28
- plugin: FastifyPluginCallback<Options> | FastifyPluginAsync<Options> | Promise<{ default: FastifyPluginCallback<Options> }> | Promise<{ default: FastifyPluginAsync<Options> }>,
29
+ <Options extends FastifyPluginOptions, Server extends RawServerBase = RawServer, TypeProvider extends FastifyTypeProvider = TypeProviderDefault>(
30
+ plugin: FastifyPluginCallback<Options, Server, TypeProvider> | FastifyPluginAsync<Options, Server, TypeProvider> | Promise<{ default: FastifyPluginCallback<Options, Server, TypeProvider> }> | Promise<{ default: FastifyPluginAsync<Options, Server, TypeProvider> }>,
29
31
  opts?: FastifyRegisterOptions<Options>
30
32
  ): T;
31
33
  }
package/types/schema.d.ts CHANGED
@@ -41,7 +41,7 @@ export type FastifySerializerCompiler<T> = (routeSchema: FastifyRouteSchemaDef<T
41
41
 
42
42
  export interface FastifySchemaControllerOptions{
43
43
  bucket?: (parentSchemas?: unknown) => {
44
- addSchema(schema: unknown): FastifyInstance;
44
+ add(schema: unknown): FastifyInstance;
45
45
  getSchema(schemaId: string): unknown;
46
46
  getSchemas(): Record<string, unknown>;
47
47
  };