@@ -34,9 +34,9 @@ are Request/Reply hooks and application hooks:
34
34
- [ Using Hooks to Inject Custom Properties] ( #using-hooks-to-inject-custom-properties )
35
35
- [ Diagnostics Channel Hooks] ( #diagnostics-channel-hooks )
36
36
37
- ** Notice: ** the ` done ` callback is not available when using ` async ` /` await ` or
38
- returning a ` Promise ` . If you do invoke a ` done ` callback in this situation
39
- unexpected behavior may occur, e.g. duplicate invocation of handlers.
37
+ > 🛈 Note: The ` done ` callback is not available when using ` async ` /` await ` or
38
+ > returning a ` Promise ` . If you do invoke a ` done ` callback in this situation
39
+ > unexpected behavior may occur, e.g. duplicate invocation of handlers.
40
40
41
41
## Request/Reply Hooks
42
42
@@ -68,9 +68,9 @@ fastify.addHook('onRequest', async (request, reply) => {
68
68
})
69
69
```
70
70
71
- ** Notice: ** in the [ onRequest] ( #onrequest ) hook, ` request.body ` will always be
72
- ` undefined ` , because the body parsing happens before the
73
- [ preValidation] ( #prevalidation ) hook.
71
+ > 🛈 Note: In the [ onRequest] ( #onrequest ) hook, ` request.body ` will always be
72
+ > ` undefined ` , because the body parsing happens before the
73
+ > [ preValidation] ( #prevalidation ) hook.
74
74
75
75
### preParsing
76
76
@@ -98,17 +98,17 @@ fastify.addHook('preParsing', async (request, reply, payload) => {
98
98
})
99
99
```
100
100
101
- ** Notice: ** in the [ preParsing] ( #preparsing ) hook, ` request.body ` will always be
102
- ` undefined ` , because the body parsing happens before the
103
- [ preValidation] ( #prevalidation ) hook.
101
+ > 🛈 Note: In the [ preParsing] ( #preparsing ) hook, ` request.body ` will always be
102
+ > ` undefined ` , because the body parsing happens before the
103
+ > [ preValidation] ( #prevalidation ) hook.
104
104
105
- ** Notice: ** you should also add a ` receivedEncodedLength ` property to the
106
- returned stream. This property is used to correctly match the request payload
107
- with the ` Content-Length ` header value. Ideally, this property should be updated
108
- on each received chunk.
105
+ > 🛈 Note: You should also add a ` receivedEncodedLength ` property to the
106
+ > returned stream. This property is used to correctly match the request payload
107
+ > with the ` Content-Length ` header value. Ideally, this property should be updated
108
+ > on each received chunk.
109
109
110
- ** Notice: ** The size of the returned stream is checked to not exceed the limit
111
- set in [ ` bodyLimit ` ] ( ./Server.md#bodylimit ) option.
110
+ > 🛈 Note: The size of the returned stream is checked to not exceed the limit
111
+ > set in [ ` bodyLimit ` ] ( ./Server.md#bodylimit ) option.
112
112
113
113
### preValidation
114
114
@@ -166,8 +166,8 @@ fastify.addHook('preSerialization', async (request, reply, payload) => {
166
166
})
167
167
```
168
168
169
- Note: the hook is NOT called if the payload is a ` string ` , a ` Buffer ` , a
170
- ` stream ` , or ` null ` .
169
+ > 🛈 Note: The hook is NOT called if the payload is a ` string ` , a ` Buffer ` , a
170
+ > ` stream ` , or ` null ` .
171
171
172
172
### onError
173
173
``` js
196
196
* (Note that the default error handler always sends the error back to the
197
197
user)* .
198
198
199
- ** Notice: ** unlike the other hooks, passing an error to the ` done ` function is not
200
- supported.
199
+ > 🛈 Note: Unlike the other hooks, passing an error to the ` done ` function is not
200
+ > supported.
201
201
202
202
### onSend
203
203
If you are using the ` onSend ` hook, you can change the payload. For example:
@@ -233,8 +233,8 @@ fastify.addHook('onSend', (request, reply, payload, done) => {
233
233
> to ` 0 ` , whereas the ` Content-Length ` header will not be set if the payload is
234
234
> ` null ` .
235
235
236
- Note: If you change the payload, you may only change it to a ` string ` , a
237
- ` Buffer ` , a ` stream ` , a ` ReadableStream ` , a ` Response ` , or ` null ` .
236
+ > 🛈 Note: If you change the payload, you may only change it to a ` string ` , a
237
+ > ` Buffer ` , a ` stream ` , a ` ReadableStream ` , a ` Response ` , or ` null ` .
238
238
239
239
240
240
### onResponse
@@ -256,8 +256,8 @@ The `onResponse` hook is executed when a response has been sent, so you will not
256
256
be able to send more data to the client. It can however be useful for sending
257
257
data to external services, for example, to gather statistics.
258
258
259
- ** Note:** setting ` disableRequestLogging ` to ` true ` will disable any error log
260
- inside the ` onResponse ` hook. In this case use ` try - catch ` to log errors.
259
+ > 🛈 Note: Setting ` disableRequestLogging ` to ` true ` will disable any error log
260
+ > inside the ` onResponse ` hook. In this case use ` try - catch ` to log errors.
261
261
262
262
### onTimeout
263
263
@@ -298,7 +298,8 @@ The `onRequestAbort` hook is executed when a client closes the connection before
298
298
the entire request has been processed. Therefore, you will not be able to send
299
299
data to the client.
300
300
301
- ** Notice:** client abort detection is not completely reliable. See: [ ` Detecting-When-Clients-Abort.md ` ] ( ../Guides/Detecting-When-Clients-Abort.md )
301
+ > 🛈 Note: Client abort detection is not completely reliable.
302
+ > See: [ ` Detecting-When-Clients-Abort.md ` ] ( ../Guides/Detecting-When-Clients-Abort.md )
302
303
303
304
### Manage Errors from a hook
304
305
If you get an error during the execution of your hook, just pass it to ` done() `
@@ -451,8 +452,8 @@ fastify.addHook('onListen', async function () {
451
452
})
452
453
```
453
454
454
- > ** Note**
455
- > This hook will not run when the server is started using ` fastify.inject() ` or ` fastify.ready() `
455
+ > 🛈 Note: This hook will not run when the server is started using
456
+ > fastify.inject()` or ` fastify.ready()`.
456
457
457
458
### onClose
458
459
<a id =" on-close " ></a >
@@ -575,8 +576,8 @@ This hook can be useful if you are developing a plugin that needs to know when a
575
576
plugin context is formed, and you want to operate in that specific context, thus
576
577
this hook is encapsulated.
577
578
578
- ** Note:** This hook will not be called if a plugin is wrapped inside
579
- [ ` fastify-plugin ` ] ( https://github.com/fastify/fastify-plugin ) .
579
+ > 🛈 Note: This hook will not be called if a plugin is wrapped inside
580
+ > [ ` fastify-plugin ` ] ( https://github.com/fastify/fastify-plugin ) .
580
581
``` js
581
582
fastify .decorate (' data' , [])
582
583
@@ -773,7 +774,7 @@ fastify.route({
773
774
})
774
775
```
775
776
776
- ** Note** : both options also accept an array of functions.
777
+ > 🛈 Note: Both options also accept an array of functions.
777
778
778
779
## Using Hooks to Inject Custom Properties
779
780
<a id =" using-hooks-to-inject-custom-properties " ></a >
@@ -860,7 +861,7 @@ channel.subscribe(function ({ fastify }) {
860
861
})
861
862
` ` `
862
863
863
- > ** Note:** The TracingChannel class API is currently experimental and may undergo
864
+ > 🛈 Note: The TracingChannel class API is currently experimental and may undergo
864
865
> breaking changes even in semver-patch releases of Node.js.
865
866
866
867
Five other events are published on a per-request basis following the
0 commit comments