fastify 4.9.0 → 4.9.1
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/docs/Reference/Decorators.md +31 -2
- package/docs/Reference/Errors.md +1 -1
- package/docs/Reference/Hooks.md +3 -3
- package/docs/Reference/Reply.md +2 -2
- package/docs/Reference/Routes.md +3 -3
- package/fastify.js +1 -1
- package/lib/route.js +1 -1
- package/package.json +1 -1
- package/test/hooks.test.js +12 -2
- package/test/logger.test.js +14 -0
- package/test/types/logger.test-d.ts +3 -1
- package/test/types/request.test-d.ts +2 -1
- package/types/hooks.d.ts +25 -25
- package/types/instance.d.ts +21 -21
- package/types/logger.d.ts +7 -3
- package/types/plugin.d.ts +3 -3
- package/types/reply.d.ts +4 -3
- package/types/request.d.ts +2 -2
- package/types/route.d.ts +9 -9
|
@@ -114,10 +114,39 @@ fastify.get('/', async function (request, reply) {
|
|
|
114
114
|
The `dependencies` parameter is an optional list of decorators that the
|
|
115
115
|
decorator being defined relies upon. This list is simply a list of string names
|
|
116
116
|
of other decorators. In the following example, the "utility" decorator depends
|
|
117
|
-
upon "greet" and "
|
|
117
|
+
upon "greet" and "hi" decorators:
|
|
118
118
|
|
|
119
119
|
```js
|
|
120
|
-
|
|
120
|
+
async function greetDecorator (fastify, opts) {
|
|
121
|
+
fastify.decorate('greet', () => {
|
|
122
|
+
return 'greet message'
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function hiDecorator (fastify, opts) {
|
|
127
|
+
fastify.decorate('hi', () => {
|
|
128
|
+
return 'hi message'
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function utilityDecorator (fastify, opts) {
|
|
133
|
+
fastify.decorate('utility', () => {
|
|
134
|
+
return `${fastify.greet()} | ${fastify.hi()}`
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
fastify.register(fastifyPlugin(greetDecorator, { name: 'greet' }))
|
|
139
|
+
fastify.register(fastifyPlugin(hiDecorator, { name: 'hi' }))
|
|
140
|
+
fastify.register(fastifyPlugin(utilityDecorator, { dependencies: ['greet', 'hi'] }))
|
|
141
|
+
|
|
142
|
+
fastify.get('/', function (req, reply) {
|
|
143
|
+
// Response: {"hello":"greet message | hi message"}
|
|
144
|
+
reply.send({ hello: fastify.utility() })
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
fastify.listen({ port: 3000 }, (err, address) => {
|
|
148
|
+
if (err) throw err
|
|
149
|
+
})
|
|
121
150
|
```
|
|
122
151
|
|
|
123
152
|
Note: using an arrow function will break the binding of `this` to the
|
package/docs/Reference/Errors.md
CHANGED
|
@@ -332,7 +332,7 @@ The router received an invalid url.
|
|
|
332
332
|
### FST_ERR_ASYNC_CONSTRAINT
|
|
333
333
|
<a id="FST_ERR_ASYNC_CONSTRAINT"></a>
|
|
334
334
|
|
|
335
|
-
The router received error when using asynchronous constraints.
|
|
335
|
+
The router received an error when using asynchronous constraints.
|
|
336
336
|
|
|
337
337
|
#### FST_ERR_DEFAULT_ROUTE_INVALID_TYPE
|
|
338
338
|
<a id="FST_ERR_DEFAULT_ROUTE_INVALID_TYPE"></a>
|
package/docs/Reference/Hooks.md
CHANGED
|
@@ -449,9 +449,9 @@ fastify.addHook('onRoute', (routeOptions) => {
|
|
|
449
449
|
})
|
|
450
450
|
```
|
|
451
451
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
recommended approach is shown below.
|
|
452
|
+
To add more routes within an onRoute hook, the routes must
|
|
453
|
+
be tagged correctly. The hook will run into an infinite loop if
|
|
454
|
+
not tagged. The recommended approach is shown below.
|
|
455
455
|
|
|
456
456
|
```js
|
|
457
457
|
const kRouteAlreadyProcessed = Symbol('route-already-processed')
|
package/docs/Reference/Reply.md
CHANGED
|
@@ -656,13 +656,13 @@ fastify.get('/json', options, function (request, reply) {
|
|
|
656
656
|
#### Streams
|
|
657
657
|
<a id="send-streams"></a>
|
|
658
658
|
|
|
659
|
-
*send* can also handle streams
|
|
660
|
-
you have not set a `'Content-Type'` header, *send* will set it at
|
|
659
|
+
*send* can also handle streams by setting the `'Content-Type'` header to
|
|
661
660
|
`'application/octet-stream'`.
|
|
662
661
|
```js
|
|
663
662
|
fastify.get('/streams', function (request, reply) {
|
|
664
663
|
const fs = require('fs')
|
|
665
664
|
const stream = fs.createReadStream('some-file', 'utf8')
|
|
665
|
+
reply.header('Content-Type', 'application/octet-stream')
|
|
666
666
|
reply.send(stream)
|
|
667
667
|
})
|
|
668
668
|
```
|
package/docs/Reference/Routes.md
CHANGED
|
@@ -734,9 +734,9 @@ fastify.route({
|
|
|
734
734
|
|
|
735
735
|
#### Asynchronous Custom Constraints
|
|
736
736
|
|
|
737
|
-
|
|
738
|
-
fetched from
|
|
739
|
-
|
|
737
|
+
Custom constraints can be provided and the `constraint` criteria can be
|
|
738
|
+
fetched from another source such as `database`. The use of asynchronous
|
|
739
|
+
custom constraints should be a last resort as it impacts router
|
|
740
740
|
performance.
|
|
741
741
|
|
|
742
742
|
```js
|
package/fastify.js
CHANGED
package/lib/route.js
CHANGED
|
@@ -252,7 +252,7 @@ function buildRouting (options) {
|
|
|
252
252
|
throw new FST_ERR_HOOK_INVALID_HANDLER(hook, typeof func)
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
-
} else if (typeof opts[hook] !== 'function') {
|
|
255
|
+
} else if (opts[hook] !== undefined && typeof opts[hook] !== 'function') {
|
|
256
256
|
throw new FST_ERR_HOOK_INVALID_HANDLER(hook, typeof opts[hook])
|
|
257
257
|
}
|
|
258
258
|
}
|
package/package.json
CHANGED
package/test/hooks.test.js
CHANGED
|
@@ -3322,12 +3322,22 @@ test('registering invalid hooks should throw an error', async t => {
|
|
|
3322
3322
|
fastify.route({
|
|
3323
3323
|
method: 'GET',
|
|
3324
3324
|
path: '/invalidHook',
|
|
3325
|
-
onRequest:
|
|
3325
|
+
onRequest: null,
|
|
3326
3326
|
async handler () {
|
|
3327
3327
|
return 'hello world'
|
|
3328
3328
|
}
|
|
3329
3329
|
})
|
|
3330
|
-
}, new Error('onRequest hook should be a function, instead got
|
|
3330
|
+
}, new Error('onRequest hook should be a function, instead got object'))
|
|
3331
|
+
|
|
3332
|
+
// undefined is ok
|
|
3333
|
+
fastify.route({
|
|
3334
|
+
method: 'GET',
|
|
3335
|
+
path: '/validhook',
|
|
3336
|
+
onRequest: undefined,
|
|
3337
|
+
async handler () {
|
|
3338
|
+
return 'hello world'
|
|
3339
|
+
}
|
|
3340
|
+
})
|
|
3331
3341
|
|
|
3332
3342
|
t.throws(() => {
|
|
3333
3343
|
fastify.addHook('onRoute', (routeOptions) => {
|
package/test/logger.test.js
CHANGED
|
@@ -1687,3 +1687,17 @@ test('should not throw error when serializing custom req', t => {
|
|
|
1687
1687
|
|
|
1688
1688
|
t.same(lines[0].req, {})
|
|
1689
1689
|
})
|
|
1690
|
+
|
|
1691
|
+
test('set bindings', t => {
|
|
1692
|
+
t.plan(1)
|
|
1693
|
+
|
|
1694
|
+
const stream = split(JSON.parse)
|
|
1695
|
+
stream.once('data', info => {
|
|
1696
|
+
t.same(info.hello, 'world')
|
|
1697
|
+
})
|
|
1698
|
+
|
|
1699
|
+
const fastify = Fastify({ logger: { level: 'info', stream } })
|
|
1700
|
+
|
|
1701
|
+
fastify.log.setBindings({ hello: 'world' })
|
|
1702
|
+
fastify.log.info('hello world')
|
|
1703
|
+
})
|
|
@@ -10,6 +10,7 @@ import fastify, {
|
|
|
10
10
|
import { Server, IncomingMessage, ServerResponse } from 'http'
|
|
11
11
|
import * as fs from 'fs'
|
|
12
12
|
import P from 'pino'
|
|
13
|
+
import { DefaultFastifyLogger } from '../../types/logger'
|
|
13
14
|
|
|
14
15
|
expectType<FastifyLoggerInstance>(fastify().log)
|
|
15
16
|
|
|
@@ -24,7 +25,7 @@ class Foo {}
|
|
|
24
25
|
expectType<void>(fastify<Server, IncomingMessage, ServerResponse, FastifyLoggerInstance>().log[logLevel as LogLevel](new Foo()))
|
|
25
26
|
})
|
|
26
27
|
|
|
27
|
-
interface CustomLogger extends
|
|
28
|
+
interface CustomLogger extends DefaultFastifyLogger {
|
|
28
29
|
customMethod(msg: string, ...args: unknown[]): void;
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -45,6 +46,7 @@ class CustomLoggerImpl implements CustomLogger {
|
|
|
45
46
|
silent (...args: unknown[]) { }
|
|
46
47
|
|
|
47
48
|
child (bindings: P.Bindings, options?: P.ChildLoggerOptions): CustomLoggerImpl { return new CustomLoggerImpl() }
|
|
49
|
+
setBindings (bindings: P.Bindings): void { }
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
const customLogger = new CustomLoggerImpl()
|
|
@@ -142,7 +142,8 @@ const customLogger: CustomLoggerInterface = {
|
|
|
142
142
|
trace: () => { },
|
|
143
143
|
debug: () => { },
|
|
144
144
|
foo: () => { }, // custom severity logger method
|
|
145
|
-
child: () => customLogger as pino.Logger<never
|
|
145
|
+
child: () => customLogger as pino.Logger<never>,
|
|
146
|
+
setBindings: () => { }
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
const serverWithCustomLogger = fastify({ logger: customLogger })
|
package/types/hooks.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { RawServerBase, RawServerDefault, RawRequestDefaultExpression, RawReplyD
|
|
|
5
5
|
import { FastifyRequest } from './request'
|
|
6
6
|
import { FastifyReply } from './reply'
|
|
7
7
|
import { FastifyError } from '@fastify/error'
|
|
8
|
-
import { FastifyBaseLogger } from './logger'
|
|
8
|
+
import { DefaultFastifyLogger, FastifyBaseLogger } from './logger'
|
|
9
9
|
import {
|
|
10
10
|
FastifyTypeProvider,
|
|
11
11
|
FastifyTypeProviderDefault
|
|
@@ -34,7 +34,7 @@ export interface onRequestHookHandler<
|
|
|
34
34
|
ContextConfig = ContextConfigDefault,
|
|
35
35
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
36
36
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
37
|
-
Logger extends FastifyBaseLogger =
|
|
37
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
38
38
|
> {
|
|
39
39
|
(
|
|
40
40
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -52,7 +52,7 @@ export interface onRequestAsyncHookHandler<
|
|
|
52
52
|
ContextConfig = ContextConfigDefault,
|
|
53
53
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
54
54
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
55
|
-
Logger extends FastifyBaseLogger =
|
|
55
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
56
56
|
> {
|
|
57
57
|
(
|
|
58
58
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -73,7 +73,7 @@ export interface preParsingHookHandler<
|
|
|
73
73
|
ContextConfig = ContextConfigDefault,
|
|
74
74
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
75
75
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
76
|
-
Logger extends FastifyBaseLogger =
|
|
76
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
77
77
|
> {
|
|
78
78
|
(
|
|
79
79
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -92,7 +92,7 @@ export interface preParsingAsyncHookHandler<
|
|
|
92
92
|
ContextConfig = ContextConfigDefault,
|
|
93
93
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
94
94
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
95
|
-
Logger extends FastifyBaseLogger =
|
|
95
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
96
96
|
> {
|
|
97
97
|
(
|
|
98
98
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -113,7 +113,7 @@ export interface preValidationHookHandler<
|
|
|
113
113
|
ContextConfig = ContextConfigDefault,
|
|
114
114
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
115
115
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
116
|
-
Logger extends FastifyBaseLogger =
|
|
116
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
117
117
|
> {
|
|
118
118
|
(
|
|
119
119
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -131,7 +131,7 @@ export interface preValidationAsyncHookHandler<
|
|
|
131
131
|
ContextConfig = ContextConfigDefault,
|
|
132
132
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
133
133
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
134
|
-
Logger extends FastifyBaseLogger =
|
|
134
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
135
135
|
> {
|
|
136
136
|
(
|
|
137
137
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -151,7 +151,7 @@ export interface preHandlerHookHandler<
|
|
|
151
151
|
ContextConfig = ContextConfigDefault,
|
|
152
152
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
153
153
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
154
|
-
Logger extends FastifyBaseLogger =
|
|
154
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
155
155
|
> {
|
|
156
156
|
(
|
|
157
157
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -169,7 +169,7 @@ export interface preHandlerAsyncHookHandler<
|
|
|
169
169
|
ContextConfig = ContextConfigDefault,
|
|
170
170
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
171
171
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
172
|
-
Logger extends FastifyBaseLogger =
|
|
172
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
173
173
|
> {
|
|
174
174
|
(
|
|
175
175
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -198,7 +198,7 @@ export interface preSerializationHookHandler<
|
|
|
198
198
|
ContextConfig = ContextConfigDefault,
|
|
199
199
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
200
200
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
201
|
-
Logger extends FastifyBaseLogger =
|
|
201
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
202
202
|
> {
|
|
203
203
|
(
|
|
204
204
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -218,7 +218,7 @@ export interface preSerializationAsyncHookHandler<
|
|
|
218
218
|
ContextConfig = ContextConfigDefault,
|
|
219
219
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
220
220
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
221
|
-
Logger extends FastifyBaseLogger =
|
|
221
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
222
222
|
> {
|
|
223
223
|
(
|
|
224
224
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -241,7 +241,7 @@ export interface onSendHookHandler<
|
|
|
241
241
|
ContextConfig = ContextConfigDefault,
|
|
242
242
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
243
243
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
244
|
-
Logger extends FastifyBaseLogger =
|
|
244
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
245
245
|
> {
|
|
246
246
|
(
|
|
247
247
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -261,7 +261,7 @@ export interface onSendAsyncHookHandler<
|
|
|
261
261
|
ContextConfig = ContextConfigDefault,
|
|
262
262
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
263
263
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
264
|
-
Logger extends FastifyBaseLogger =
|
|
264
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
265
265
|
> {
|
|
266
266
|
(
|
|
267
267
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -283,7 +283,7 @@ export interface onResponseHookHandler<
|
|
|
283
283
|
ContextConfig = ContextConfigDefault,
|
|
284
284
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
285
285
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
286
|
-
Logger extends FastifyBaseLogger =
|
|
286
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
287
287
|
> {
|
|
288
288
|
(
|
|
289
289
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -301,7 +301,7 @@ export interface onResponseAsyncHookHandler<
|
|
|
301
301
|
ContextConfig = ContextConfigDefault,
|
|
302
302
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
303
303
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
304
|
-
Logger extends FastifyBaseLogger =
|
|
304
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
305
305
|
> {
|
|
306
306
|
(
|
|
307
307
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -322,7 +322,7 @@ export interface onTimeoutHookHandler<
|
|
|
322
322
|
ContextConfig = ContextConfigDefault,
|
|
323
323
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
324
324
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
325
|
-
Logger extends FastifyBaseLogger =
|
|
325
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
326
326
|
> {
|
|
327
327
|
(
|
|
328
328
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -340,7 +340,7 @@ export interface onTimeoutAsyncHookHandler<
|
|
|
340
340
|
ContextConfig = ContextConfigDefault,
|
|
341
341
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
342
342
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
343
|
-
Logger extends FastifyBaseLogger =
|
|
343
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
344
344
|
> {
|
|
345
345
|
(
|
|
346
346
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -364,7 +364,7 @@ export interface onErrorHookHandler<
|
|
|
364
364
|
TError extends Error = FastifyError,
|
|
365
365
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
366
366
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
367
|
-
Logger extends FastifyBaseLogger =
|
|
367
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
368
368
|
> {
|
|
369
369
|
(
|
|
370
370
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -384,7 +384,7 @@ export interface onErrorAsyncHookHandler<
|
|
|
384
384
|
TError extends Error = FastifyError,
|
|
385
385
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
386
386
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
387
|
-
Logger extends FastifyBaseLogger =
|
|
387
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
388
388
|
> {
|
|
389
389
|
(
|
|
390
390
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -407,7 +407,7 @@ export interface onRouteHookHandler<
|
|
|
407
407
|
ContextConfig = ContextConfigDefault,
|
|
408
408
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
409
409
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
410
|
-
Logger extends FastifyBaseLogger =
|
|
410
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
411
411
|
> {
|
|
412
412
|
(
|
|
413
413
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
@@ -424,7 +424,7 @@ export interface onRegisterHookHandler<
|
|
|
424
424
|
RawServer extends RawServerBase = RawServerDefault,
|
|
425
425
|
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
|
|
426
426
|
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
|
|
427
|
-
Logger extends FastifyBaseLogger =
|
|
427
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger,
|
|
428
428
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
429
429
|
Options extends FastifyPluginOptions = FastifyPluginOptions
|
|
430
430
|
> {
|
|
@@ -442,7 +442,7 @@ export interface onReadyHookHandler<
|
|
|
442
442
|
RawServer extends RawServerBase = RawServerDefault,
|
|
443
443
|
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
|
|
444
444
|
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
|
|
445
|
-
Logger extends FastifyBaseLogger =
|
|
445
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger,
|
|
446
446
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
447
447
|
> {
|
|
448
448
|
(
|
|
@@ -455,7 +455,7 @@ export interface onReadyAsyncHookHandler<
|
|
|
455
455
|
RawServer extends RawServerBase = RawServerDefault,
|
|
456
456
|
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
|
|
457
457
|
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
|
|
458
|
-
Logger extends FastifyBaseLogger =
|
|
458
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger,
|
|
459
459
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
460
460
|
> {
|
|
461
461
|
(
|
|
@@ -469,7 +469,7 @@ export interface onCloseHookHandler<
|
|
|
469
469
|
RawServer extends RawServerBase = RawServerDefault,
|
|
470
470
|
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
|
|
471
471
|
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
|
|
472
|
-
Logger extends FastifyBaseLogger =
|
|
472
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger,
|
|
473
473
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
474
474
|
> {
|
|
475
475
|
(
|
|
@@ -482,7 +482,7 @@ export interface onCloseAsyncHookHandler<
|
|
|
482
482
|
RawServer extends RawServerBase = RawServerDefault,
|
|
483
483
|
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
|
|
484
484
|
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
|
|
485
|
-
Logger extends FastifyBaseLogger =
|
|
485
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger,
|
|
486
486
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault
|
|
487
487
|
> {
|
|
488
488
|
(
|
package/types/instance.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as http from 'http'
|
|
|
4
4
|
import { CallbackFunc as LightMyRequestCallback, Chain as LightMyRequestChain, InjectOptions, Response as LightMyRequestResponse } from 'light-my-request'
|
|
5
5
|
import { AddContentTypeParser, ConstructorAction, FastifyBodyParser, getDefaultJsonParser, hasContentTypeParser, ProtoAction, removeAllContentTypeParsers, removeContentTypeParser } from './content-type-parser'
|
|
6
6
|
import { onCloseAsyncHookHandler, onCloseHookHandler, onErrorAsyncHookHandler, onErrorHookHandler, onReadyAsyncHookHandler, onReadyHookHandler, onRegisterHookHandler, onRequestAsyncHookHandler, onRequestHookHandler, onResponseAsyncHookHandler, onResponseHookHandler, onRouteHookHandler, onSendAsyncHookHandler, onSendHookHandler, onTimeoutAsyncHookHandler, onTimeoutHookHandler, preHandlerAsyncHookHandler, preHandlerHookHandler, preParsingAsyncHookHandler, preParsingHookHandler, preSerializationAsyncHookHandler, preSerializationHookHandler, preValidationAsyncHookHandler, preValidationHookHandler } from './hooks'
|
|
7
|
-
import { FastifyBaseLogger } from './logger'
|
|
7
|
+
import { DefaultFastifyLogger, FastifyBaseLogger } from './logger'
|
|
8
8
|
import { FastifyRegister } from './register'
|
|
9
9
|
import { FastifyReply } from './reply'
|
|
10
10
|
import { FastifyRequest } from './request'
|
|
@@ -84,7 +84,7 @@ export interface FastifyInstance<
|
|
|
84
84
|
RawServer extends RawServerBase = RawServerDefault,
|
|
85
85
|
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
|
|
86
86
|
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
|
|
87
|
-
Logger extends FastifyBaseLogger =
|
|
87
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger,
|
|
88
88
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
89
89
|
> {
|
|
90
90
|
server: RawServer;
|
|
@@ -204,7 +204,7 @@ export interface FastifyInstance<
|
|
|
204
204
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
205
205
|
ContextConfig = ContextConfigDefault,
|
|
206
206
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
207
|
-
Logger extends FastifyBaseLogger =
|
|
207
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
208
208
|
>(
|
|
209
209
|
name: 'onRequest',
|
|
210
210
|
hook: onRequestHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -214,7 +214,7 @@ export interface FastifyInstance<
|
|
|
214
214
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
215
215
|
ContextConfig = ContextConfigDefault,
|
|
216
216
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
217
|
-
Logger extends FastifyBaseLogger =
|
|
217
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
218
218
|
>(
|
|
219
219
|
name: 'onRequest',
|
|
220
220
|
hook: onRequestAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -228,7 +228,7 @@ export interface FastifyInstance<
|
|
|
228
228
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
229
229
|
ContextConfig = ContextConfigDefault,
|
|
230
230
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
231
|
-
Logger extends FastifyBaseLogger =
|
|
231
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
232
232
|
>(
|
|
233
233
|
name: 'preParsing',
|
|
234
234
|
hook: preParsingHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -238,7 +238,7 @@ export interface FastifyInstance<
|
|
|
238
238
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
239
239
|
ContextConfig = ContextConfigDefault,
|
|
240
240
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
241
|
-
Logger extends FastifyBaseLogger =
|
|
241
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
242
242
|
>(
|
|
243
243
|
name: 'preParsing',
|
|
244
244
|
hook: preParsingAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -251,7 +251,7 @@ export interface FastifyInstance<
|
|
|
251
251
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
252
252
|
ContextConfig = ContextConfigDefault,
|
|
253
253
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
254
|
-
Logger extends FastifyBaseLogger =
|
|
254
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
255
255
|
>(
|
|
256
256
|
name: 'preValidation',
|
|
257
257
|
hook: preValidationHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -261,7 +261,7 @@ export interface FastifyInstance<
|
|
|
261
261
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
262
262
|
ContextConfig = ContextConfigDefault,
|
|
263
263
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
264
|
-
Logger extends FastifyBaseLogger =
|
|
264
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
265
265
|
>(
|
|
266
266
|
name: 'preValidation',
|
|
267
267
|
hook: preValidationAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -274,7 +274,7 @@ export interface FastifyInstance<
|
|
|
274
274
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
275
275
|
ContextConfig = ContextConfigDefault,
|
|
276
276
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
277
|
-
Logger extends FastifyBaseLogger =
|
|
277
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
278
278
|
>(
|
|
279
279
|
name: 'preHandler',
|
|
280
280
|
hook: preHandlerHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -284,7 +284,7 @@ export interface FastifyInstance<
|
|
|
284
284
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
285
285
|
ContextConfig = ContextConfigDefault,
|
|
286
286
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
287
|
-
Logger extends FastifyBaseLogger =
|
|
287
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
288
288
|
>(
|
|
289
289
|
name: 'preHandler',
|
|
290
290
|
hook: preHandlerAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -299,7 +299,7 @@ export interface FastifyInstance<
|
|
|
299
299
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
300
300
|
ContextConfig = ContextConfigDefault,
|
|
301
301
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
302
|
-
Logger extends FastifyBaseLogger =
|
|
302
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
303
303
|
>(
|
|
304
304
|
name: 'preSerialization',
|
|
305
305
|
hook: preSerializationHookHandler<PreSerializationPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -310,7 +310,7 @@ export interface FastifyInstance<
|
|
|
310
310
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
311
311
|
ContextConfig = ContextConfigDefault,
|
|
312
312
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
313
|
-
Logger extends FastifyBaseLogger =
|
|
313
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
314
314
|
>(
|
|
315
315
|
name: 'preSerialization',
|
|
316
316
|
hook: preSerializationAsyncHookHandler<PreSerializationPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -325,7 +325,7 @@ export interface FastifyInstance<
|
|
|
325
325
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
326
326
|
ContextConfig = ContextConfigDefault,
|
|
327
327
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
328
|
-
Logger extends FastifyBaseLogger =
|
|
328
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
329
329
|
>(
|
|
330
330
|
name: 'onSend',
|
|
331
331
|
hook: onSendHookHandler<OnSendPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -336,7 +336,7 @@ export interface FastifyInstance<
|
|
|
336
336
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
337
337
|
ContextConfig = ContextConfigDefault,
|
|
338
338
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
339
|
-
Logger extends FastifyBaseLogger =
|
|
339
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
340
340
|
>(
|
|
341
341
|
name: 'onSend',
|
|
342
342
|
hook: onSendAsyncHookHandler<OnSendPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -350,7 +350,7 @@ export interface FastifyInstance<
|
|
|
350
350
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
351
351
|
ContextConfig = ContextConfigDefault,
|
|
352
352
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
353
|
-
Logger extends FastifyBaseLogger =
|
|
353
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
354
354
|
>(
|
|
355
355
|
name: 'onResponse',
|
|
356
356
|
hook: onResponseHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -360,7 +360,7 @@ export interface FastifyInstance<
|
|
|
360
360
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
361
361
|
ContextConfig = ContextConfigDefault,
|
|
362
362
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
363
|
-
Logger extends FastifyBaseLogger =
|
|
363
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
364
364
|
>(
|
|
365
365
|
name: 'onResponse',
|
|
366
366
|
hook: onResponseAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -374,7 +374,7 @@ export interface FastifyInstance<
|
|
|
374
374
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
375
375
|
ContextConfig = ContextConfigDefault,
|
|
376
376
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
377
|
-
Logger extends FastifyBaseLogger =
|
|
377
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
378
378
|
>(
|
|
379
379
|
name: 'onTimeout',
|
|
380
380
|
hook: onTimeoutHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -384,7 +384,7 @@ export interface FastifyInstance<
|
|
|
384
384
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
385
385
|
ContextConfig = ContextConfigDefault,
|
|
386
386
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
387
|
-
Logger extends FastifyBaseLogger =
|
|
387
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
388
388
|
>(
|
|
389
389
|
name: 'onTimeout',
|
|
390
390
|
hook: onTimeoutAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -400,7 +400,7 @@ export interface FastifyInstance<
|
|
|
400
400
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
401
401
|
ContextConfig = ContextConfigDefault,
|
|
402
402
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
403
|
-
Logger extends FastifyBaseLogger =
|
|
403
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
404
404
|
>(
|
|
405
405
|
name: 'onError',
|
|
406
406
|
hook: onErrorHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, FastifyError, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -410,7 +410,7 @@ export interface FastifyInstance<
|
|
|
410
410
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
411
411
|
ContextConfig = ContextConfigDefault,
|
|
412
412
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
413
|
-
Logger extends FastifyBaseLogger =
|
|
413
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
414
414
|
>(
|
|
415
415
|
name: 'onError',
|
|
416
416
|
hook: onErrorAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, FastifyError, SchemaCompiler, TypeProvider, Logger>
|
|
@@ -425,7 +425,7 @@ export interface FastifyInstance<
|
|
|
425
425
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
426
426
|
ContextConfig = ContextConfigDefault,
|
|
427
427
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
428
|
-
Logger extends FastifyBaseLogger =
|
|
428
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
429
429
|
>(
|
|
430
430
|
name: 'onRoute',
|
|
431
431
|
hook: onRouteHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
package/types/logger.d.ts
CHANGED
|
@@ -19,15 +19,19 @@ export type Bindings = pino.Bindings
|
|
|
19
19
|
|
|
20
20
|
export type ChildLoggerOptions = pino.ChildLoggerOptions
|
|
21
21
|
|
|
22
|
-
export
|
|
23
|
-
child(bindings: Bindings, options?: ChildLoggerOptions):
|
|
22
|
+
export interface FastifyBaseLogger<T extends FastifyBaseLogger<any> = FastifyBaseLogger<any>> extends pino.BaseLogger {
|
|
23
|
+
child(bindings: Bindings, options?: ChildLoggerOptions): T
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DefaultFastifyLogger extends FastifyBaseLogger<DefaultFastifyLogger>, Pick<pino.Logger, 'setBindings'> {
|
|
27
|
+
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
// TODO delete FastifyBaseLogger in the next major release. It seems that it is enough to have only FastifyBaseLogger.
|
|
27
31
|
/**
|
|
28
32
|
* @deprecated Use FastifyBaseLogger instead
|
|
29
33
|
*/
|
|
30
|
-
export type FastifyLoggerInstance =
|
|
34
|
+
export type FastifyLoggerInstance = DefaultFastifyLogger
|
|
31
35
|
|
|
32
36
|
export interface FastifyLoggerStreamDestination {
|
|
33
37
|
write(msg: string): void;
|
package/types/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FastifyInstance } from './instance'
|
|
2
2
|
import { RawServerBase, RawRequestDefaultExpression, RawReplyDefaultExpression, RawServerDefault } from './utils'
|
|
3
3
|
import { FastifyTypeProvider, FastifyTypeProviderDefault } from './type-provider'
|
|
4
|
-
import {
|
|
4
|
+
import { DefaultFastifyLogger } from './logger'
|
|
5
5
|
|
|
6
6
|
export type FastifyPluginOptions = Record<string, any>
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ export type FastifyPluginOptions = Record<string, any>
|
|
|
11
11
|
* Fastify allows the user to extend its functionalities with plugins. A plugin can be a set of routes, a server decorator or whatever. To activate plugins, use the `fastify.register()` method.
|
|
12
12
|
*/
|
|
13
13
|
export type FastifyPluginCallback<Options extends FastifyPluginOptions = Record<never, never>, Server extends RawServerBase = RawServerDefault, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault> = (
|
|
14
|
-
instance: FastifyInstance<Server, RawRequestDefaultExpression<Server>, RawReplyDefaultExpression<Server>,
|
|
14
|
+
instance: FastifyInstance<Server, RawRequestDefaultExpression<Server>, RawReplyDefaultExpression<Server>, DefaultFastifyLogger, TypeProvider>,
|
|
15
15
|
opts: Options,
|
|
16
16
|
done: (err?: Error) => void
|
|
17
17
|
) => void
|
|
@@ -26,7 +26,7 @@ export type FastifyPluginAsync<
|
|
|
26
26
|
Server extends RawServerBase = RawServerDefault,
|
|
27
27
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
28
28
|
> = (
|
|
29
|
-
instance: FastifyInstance<Server, RawRequestDefaultExpression<Server>, RawReplyDefaultExpression<Server>,
|
|
29
|
+
instance: FastifyInstance<Server, RawRequestDefaultExpression<Server>, RawReplyDefaultExpression<Server>, DefaultFastifyLogger, TypeProvider>,
|
|
30
30
|
opts: Options
|
|
31
31
|
) => Promise<void>;
|
|
32
32
|
|
package/types/reply.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RawReplyDefaultExpression, RawServerBase, RawServerDefault, ContextConfigDefault, RawRequestDefaultExpression, ReplyDefault } from './utils'
|
|
2
2
|
import { FastifyReplyType, ResolveFastifyReplyType, FastifyTypeProvider, FastifyTypeProviderDefault } from './type-provider'
|
|
3
3
|
import { FastifyContext } from './context'
|
|
4
|
-
import { FastifyBaseLogger } from './logger'
|
|
4
|
+
import { DefaultFastifyLogger, FastifyBaseLogger } from './logger'
|
|
5
5
|
import { FastifyRequest } from './request'
|
|
6
6
|
import { RouteGenericInterface } from './route'
|
|
7
7
|
import { FastifyInstance } from './instance'
|
|
@@ -24,11 +24,12 @@ export interface FastifyReply<
|
|
|
24
24
|
ContextConfig = ContextConfigDefault,
|
|
25
25
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
26
26
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
27
|
-
ReplyType extends FastifyReplyType = ResolveFastifyReplyType<TypeProvider, SchemaCompiler, RouteGeneric
|
|
27
|
+
ReplyType extends FastifyReplyType = ResolveFastifyReplyType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
28
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger,
|
|
28
29
|
> {
|
|
29
30
|
raw: RawReply;
|
|
30
31
|
context: FastifyContext<ContextConfig>;
|
|
31
|
-
log:
|
|
32
|
+
log: Logger;
|
|
32
33
|
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>;
|
|
33
34
|
server: FastifyInstance;
|
|
34
35
|
code(statusCode: number): FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>;
|
package/types/request.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorObject } from '@fastify/ajv-compiler'
|
|
2
|
-
import { FastifyBaseLogger } from './logger'
|
|
2
|
+
import { DefaultFastifyLogger, FastifyBaseLogger } from './logger'
|
|
3
3
|
import { ContextConfigDefault, RawServerBase, RawServerDefault, RawRequestDefaultExpression, RequestBodyDefault, RequestQuerystringDefault, RequestParamsDefault, RequestHeadersDefault } from './utils'
|
|
4
4
|
import { RouteGenericInterface } from './route'
|
|
5
5
|
import { FastifyInstance } from './instance'
|
|
@@ -30,7 +30,7 @@ export interface FastifyRequest<RouteGeneric extends RouteGenericInterface = Rou
|
|
|
30
30
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
31
31
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
32
32
|
ContextConfig = ContextConfigDefault,
|
|
33
|
-
Logger extends FastifyBaseLogger =
|
|
33
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger,
|
|
34
34
|
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>
|
|
35
35
|
// ^ Temporary Note: RequestType has been re-ordered to be the last argument in
|
|
36
36
|
// generic list. This generic argument is now considered optional as it can be
|
package/types/route.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
FastifyTypeProviderDefault,
|
|
12
12
|
ResolveFastifyReplyReturnType
|
|
13
13
|
} from './type-provider'
|
|
14
|
-
import { FastifyBaseLogger, LogLevel } from './logger'
|
|
14
|
+
import { DefaultFastifyLogger, FastifyBaseLogger, LogLevel } from './logger'
|
|
15
15
|
|
|
16
16
|
export interface RouteGenericInterface extends RequestGenericInterface, ReplyGenericInterface {}
|
|
17
17
|
|
|
@@ -26,7 +26,7 @@ export interface RouteShorthandOptions<
|
|
|
26
26
|
ContextConfig = ContextConfigDefault,
|
|
27
27
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
28
28
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
29
|
-
Logger extends FastifyBaseLogger =
|
|
29
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
30
30
|
> {
|
|
31
31
|
schema?: SchemaCompiler, // originally FastifySchema
|
|
32
32
|
attachValidation?: boolean;
|
|
@@ -67,7 +67,7 @@ export type RouteHandlerMethod<
|
|
|
67
67
|
ContextConfig = ContextConfigDefault,
|
|
68
68
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
69
69
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
70
|
-
Logger extends FastifyBaseLogger =
|
|
70
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
71
71
|
> = (
|
|
72
72
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
73
73
|
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
@@ -86,7 +86,7 @@ export interface RouteShorthandOptionsWithHandler<
|
|
|
86
86
|
ContextConfig = ContextConfigDefault,
|
|
87
87
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
88
88
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
89
|
-
Logger extends FastifyBaseLogger =
|
|
89
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
90
90
|
> extends RouteShorthandOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger> {
|
|
91
91
|
handler: RouteHandlerMethod<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>;
|
|
92
92
|
}
|
|
@@ -100,16 +100,16 @@ export interface RouteShorthandMethod<
|
|
|
100
100
|
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
|
|
101
101
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
102
102
|
> {
|
|
103
|
-
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyBaseLogger =
|
|
103
|
+
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyBaseLogger = DefaultFastifyLogger>(
|
|
104
104
|
path: string,
|
|
105
105
|
opts: RouteShorthandOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>,
|
|
106
106
|
handler: RouteHandlerMethod<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
107
107
|
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
108
|
-
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyBaseLogger =
|
|
108
|
+
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyBaseLogger = DefaultFastifyLogger>(
|
|
109
109
|
path: string,
|
|
110
110
|
handler: RouteHandlerMethod<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
111
111
|
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
112
|
-
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyBaseLogger =
|
|
112
|
+
<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyBaseLogger = DefaultFastifyLogger>(
|
|
113
113
|
path: string,
|
|
114
114
|
opts: RouteShorthandOptionsWithHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
|
|
115
115
|
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
@@ -126,7 +126,7 @@ export interface RouteOptions<
|
|
|
126
126
|
ContextConfig = ContextConfigDefault,
|
|
127
127
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
128
128
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
129
|
-
Logger extends FastifyBaseLogger =
|
|
129
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
130
130
|
> extends RouteShorthandOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger> {
|
|
131
131
|
method: HTTPMethods | HTTPMethods[];
|
|
132
132
|
url: string;
|
|
@@ -141,7 +141,7 @@ export type RouteHandler<
|
|
|
141
141
|
ContextConfig = ContextConfigDefault,
|
|
142
142
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
143
143
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
144
|
-
Logger extends FastifyBaseLogger =
|
|
144
|
+
Logger extends FastifyBaseLogger = DefaultFastifyLogger
|
|
145
145
|
> = (
|
|
146
146
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
147
147
|
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|