Skip to content

Commit 96c40c0

Browse files
FdawgsCopilot
andauthored
docs: fix note style (#6487)
* docs: fix note style * Update Hooks.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Frazer Smith <frazer.dev@icloud.com> * Update docs/Reference/Reply.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Frazer Smith <frazer.dev@icloud.com> * Update docs/Reference/Logging.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Frazer Smith <frazer.dev@icloud.com> --------- Signed-off-by: Frazer Smith <frazer.dev@icloud.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d0c2f45 commit 96c40c0

13 files changed

Lines changed: 104 additions & 60 deletions

docs/Guides/Fluent-Schema.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,6 @@ const schema = { body: bodyJsonSchema }
122122
fastify.post('/the/url', { schema }, handler)
123123
```
124124

125-
> ℹ️ Note: You can mix up the `$ref-way` and the `replace-way`
125+
> ℹ️ Note:
126+
> You can mix up the `$ref-way` and the `replace-way`
126127
> when using `fastify.addSchema`.

docs/Guides/Migration-Guide-V4.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ If you need to use middleware, use
8383
continue to be maintained.
8484
However, it is strongly recommended that you migrate to Fastify's [hooks](../Reference/Hooks.md).
8585

86-
> **Note**: Codemod remove `app.use()` with:
87-
>
86+
> ℹ️ Note:
87+
> Codemod remove `app.use()` with:
8888
> ```bash
8989
> npx codemod@latest fastify/4/remove-app-use
9090
> ```
@@ -94,8 +94,8 @@ However, it is strongly recommended that you migrate to Fastify's [hooks](../Ref
9494
If you previously used the `reply.res` attribute to access the underlying Request
9595
object you will now need to use `reply.raw`.
9696
97-
> **Note**: Codemod `reply.res` to `reply.raw` with:
98-
>
97+
> ℹ️ Note:
98+
> Codemod `reply.res` to `reply.raw` with:
9999
> ```bash
100100
> npx codemod@latest fastify/4/reply-raw-access
101101
> ```
@@ -146,8 +146,9 @@ As a result, if you specify an `onRoute` hook in a plugin you should now either:
146146
done();
147147
});
148148
```
149-
> **Note**: Codemod synchronous route definitions with:
150-
>
149+
150+
> ℹ️ Note:
151+
> Codemod synchronous route definitions with:
151152
> ```bash
152153
> npx codemod@latest fastify/4/wrap-routes-plugin
153154
> ```
@@ -176,8 +177,8 @@ As a result, if you specify an `onRoute` hook in a plugin you should now either:
176177
});
177178
```
178179
179-
> **Note**: Codemod 'await register(...)' with:
180-
>
180+
> ℹ️ Note:
181+
> Codemod 'await register(...)' with:
181182
> ```bash
182183
> npx codemod@latest fastify/4/await-register-calls
183184
> ```

docs/Reference/ContentTypeParser.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ fastify.addContentTypeParser('text/xml', function (request, payload, done) {
152152
})
153153
```
154154

155-
> ℹ️ Note: `function(req, done)` and `async function(req)` are
155+
> ℹ️ Note:
156+
> `function(req, done)` and `async function(req)` are
156157
> still supported but deprecated.
157158
158159
#### Body Parser

docs/Reference/Decorators.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ fastify.register(async function (fastify) {
399399
})
400400
```
401401
402-
> ℹ️ Note: For TypeScript users, `getDecorator` supports generic type parameters.
402+
> ℹ️ Note:
403+
> For TypeScript users, `getDecorator` supports generic type parameters.
403404
> See the [TypeScript documentation](/docs/Reference/TypeScript.md) for
404405
> advanced typing examples.
405406
@@ -429,6 +430,7 @@ fastify.addHook('preHandler', async (req, reply) => {
429430
})
430431
```
431432
432-
> ℹ️ Note: For TypeScript users, see the
433+
> ℹ️ Note:
434+
> For TypeScript users, see the
433435
> [TypeScript documentation](/docs/Reference/TypeScript.md) for advanced
434436
> typing examples using `setDecorator<T>`.

docs/Reference/Hooks.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ are Request/Reply hooks and application hooks:
3434
- [Using Hooks to Inject Custom Properties](#using-hooks-to-inject-custom-properties)
3535
- [Diagnostics Channel Hooks](#diagnostics-channel-hooks)
3636

37-
> ℹ️ Note: The `done` callback is not available when using `async`/`await` or
37+
> ℹ️ Note:
38+
> The `done` callback is not available when using `async`/`await` or
3839
> returning a `Promise`. If you do invoke a `done` callback in this situation
3940
> unexpected behavior may occur, e.g. duplicate invocation of handlers.
4041
@@ -68,7 +69,8 @@ fastify.addHook('onRequest', async (request, reply) => {
6869
})
6970
```
7071

71-
> ℹ️ Note: In the [onRequest](#onrequest) hook, `request.body` will always be
72+
> ℹ️ Note:
73+
> In the [onRequest](#onrequest) hook, `request.body` will always be
7274
> `undefined`, because the body parsing happens before the
7375
> [preValidation](#prevalidation) hook.
7476
@@ -98,16 +100,19 @@ fastify.addHook('preParsing', async (request, reply, payload) => {
98100
})
99101
```
100102

101-
> ℹ️ Note: In the [preParsing](#preparsing) hook, `request.body` will always be
103+
> ℹ️ Note:
104+
> In the [preParsing](#preparsing) hook, `request.body` will always be
102105
> `undefined`, because the body parsing happens before the
103106
> [preValidation](#prevalidation) hook.
104107
105-
> ℹ️ Note: You should also add a `receivedEncodedLength` property to the
108+
> ℹ️ Note:
109+
> You should also add a `receivedEncodedLength` property to the
106110
> returned stream. This property is used to correctly match the request payload
107111
> with the `Content-Length` header value. Ideally, this property should be updated
108112
> on each received chunk.
109113
110-
> ℹ️ Note: The size of the returned stream is checked to not exceed the limit
114+
> ℹ️ Note:
115+
> The size of the returned stream is checked to not exceed the limit
111116
> set in [`bodyLimit`](./Server.md#bodylimit) option.
112117
113118
### preValidation
@@ -166,7 +171,8 @@ fastify.addHook('preSerialization', async (request, reply, payload) => {
166171
})
167172
```
168173

169-
> ℹ️ Note: The hook is NOT called if the payload is a `string`, a `Buffer`, a
174+
> ℹ️ Note:
175+
> The hook is NOT called if the payload is a `string`, a `Buffer`, a
170176
> `stream`, or `null`.
171177
172178
### onError
@@ -192,7 +198,8 @@ an exception.
192198
This hook will be executed before
193199
the [Custom Error Handler set by `setErrorHandler`](./Server.md#seterrorhandler).
194200

195-
> ℹ️ Note: Unlike the other hooks, passing an error to the `done` function is not
201+
> ℹ️ Note:
202+
> Unlike the other hooks, passing an error to the `done` function is not
196203
> supported.
197204
198205
### onSend
@@ -229,7 +236,8 @@ fastify.addHook('onSend', (request, reply, payload, done) => {
229236
> to `0`, whereas the `Content-Length` header will not be set if the payload is
230237
> `null`.
231238
232-
> ℹ️ Note: If you change the payload, you may only change it to a `string`, a
239+
> ℹ️ Note:
240+
> If you change the payload, you may only change it to a `string`, a
233241
> `Buffer`, a `stream`, a `ReadableStream`, a `Response`, or `null`.
234242
235243

@@ -252,7 +260,8 @@ The `onResponse` hook is executed when a response has been sent, so you will not
252260
be able to send more data to the client. It can however be useful for sending
253261
data to external services, for example, to gather statistics.
254262

255-
> ℹ️ Note: Setting `disableRequestLogging` to `true` will disable any error log
263+
> ℹ️ Note:
264+
> Setting `disableRequestLogging` to `true` will disable any error log
256265
> inside the `onResponse` hook. In this case use `try - catch` to log errors.
257266
258267
### onTimeout
@@ -294,7 +303,8 @@ The `onRequestAbort` hook is executed when a client closes the connection before
294303
the entire request has been processed. Therefore, you will not be able to send
295304
data to the client.
296305

297-
> ℹ️ Note: Client abort detection is not completely reliable.
306+
> ℹ️ Note:
307+
> Client abort detection is not completely reliable.
298308
> See: [`Detecting-When-Clients-Abort.md`](../Guides/Detecting-When-Clients-Abort.md)
299309
300310
### Manage Errors from a hook
@@ -448,8 +458,9 @@ fastify.addHook('onListen', async function () {
448458
})
449459
```
450460

451-
> ℹ️ Note: This hook will not run when the server is started using
452-
> fastify.inject()` or `fastify.ready()`.
461+
> ℹ️ Note:
462+
> This hook will not run when the server is started using
463+
> `fastify.inject()` or `fastify.ready()`.
453464
454465
### onClose
455466
<a id="on-close"></a>
@@ -572,7 +583,8 @@ This hook can be useful if you are developing a plugin that needs to know when a
572583
plugin context is formed, and you want to operate in that specific context, thus
573584
this hook is encapsulated.
574585

575-
> ℹ️ Note: This hook will not be called if a plugin is wrapped inside
586+
> ℹ️ Note:
587+
> This hook will not be called if a plugin is wrapped inside
576588
> [`fastify-plugin`](https://github.com/fastify/fastify-plugin).
577589
```js
578590
fastify.decorate('data', [])
@@ -770,7 +782,8 @@ fastify.route({
770782
})
771783
```
772784

773-
> ℹ️ Note: Both options also accept an array of functions.
785+
> ℹ️ Note:
786+
> Both options also accept an array of functions.
774787
775788
## Using Hooks to Inject Custom Properties
776789
<a id="using-hooks-to-inject-custom-properties"></a>
@@ -857,7 +870,8 @@ channel.subscribe(function ({ fastify }) {
857870
})
858871
```
859872
860-
> ℹ️ Note: The TracingChannel class API is currently experimental and may undergo
873+
> ℹ️ Note:
874+
> The TracingChannel class API is currently experimental and may undergo
861875
> breaking changes even in semver-patch releases of Node.js.
862876
863877
Five other events are published on a per-request basis following the

docs/Reference/Logging.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ value is used; otherwise, a new incremental ID is generated. See Fastify Factory
107107
[`requestIdHeader`](./Server.md#factory-request-id-header) and Fastify Factory
108108
[`genReqId`](./Server.md#genreqid) for customization options.
109109
110-
> ⚠ Warning: enabling `requestIdHeader` allows any callers to set `reqId` to a
110+
> ⚠ Warning:
111+
> Enabling `requestIdHeader` allows any callers to set `reqId` to a
111112
> value of their choosing.
112113
> No validation is performed on `requestIdHeader`.
113114
@@ -161,7 +162,8 @@ const fastify = require('fastify')({
161162
});
162163
```
163164
164-
> ℹ️ Note: In some cases, the [`Reply`](./Reply.md) object passed to the `res`
165+
> ℹ️ Note:
166+
> In some cases, the [`Reply`](./Reply.md) object passed to the `res`
165167
> serializer cannot be fully constructed. When writing a custom `res`
166168
> serializer, check for the existence of any properties on `reply` aside from
167169
> `statusCode`, which is always present. For example, verify the existence of
@@ -188,9 +190,10 @@ const fastify = require('fastify')({
188190
});
189191
```
190192
191-
> ℹ️ Note: The body cannot be serialized inside a `req` method because the
192-
request is serialized when the child logger is created. At that time, the body
193-
is not yet parsed.
193+
> ℹ️ Note:
194+
> The body cannot be serialized inside a `req` method because the
195+
> request is serialized when the child logger is created. At that time, the body
196+
> is not yet parsed.
194197
195198
See the following approach to log `req.body`:
196199
@@ -203,7 +206,8 @@ app.addHook('preHandler', function (req, reply, done) {
203206
})
204207
```
205208
206-
> ℹ️ Note: Ensure serializers never throw errors, as this can cause the Node
209+
> ℹ️ Note:
210+
> Ensure serializers never throw errors, as this can cause the Node
207211
> process to exit. See the
208212
> [Pino documentation](https://getpino.io/#/docs/api?id=opt-serializers) for more
209213
> information.

docs/Reference/Middleware.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ that already has the Fastify [Request](./Request.md#request) and
5050
To run middleware under certain paths, pass the path as the first parameter to
5151
`use`.
5252

53-
> ℹ️ Note: This does not support routes with parameters
53+
> ℹ️ Note:
54+
> This does not support routes with parameters
5455
> (e.g. `/user/:id/comments`) and wildcards are not supported in multiple paths.
5556
5657
```js
@@ -75,4 +76,4 @@ Fastify offers alternatives to commonly used middleware, such as
7576
[`@fastify/cors`](https://github.com/fastify/fastify-cors) for
7677
[`cors`](https://github.com/expressjs/cors), and
7778
[`@fastify/static`](https://github.com/fastify/fastify-static) for
78-
[`serve-static`](https://github.com/expressjs/serve-static).
79+
[`serve-static`](https://github.com/expressjs/serve-static).

docs/Reference/Reply.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ fastify.get('/', async function (req, rep) {
152152
Sets a response header. If the value is omitted or undefined, it is coerced to
153153
`''`.
154154

155-
> ℹ️ Note: The header's value must be properly encoded using
155+
> ℹ️ Note:
156+
> The header's value must be properly encoded using
156157
> [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI)
157158
> or similar modules such as
158159
> [`encodeurl`](https://www.npmjs.com/package/encodeurl). Invalid characters
@@ -261,11 +262,13 @@ requires heavy resources to be sent after the `data`, for example,
261262
`Server-Timing` and `Etag`. It can ensure the client receives the response data
262263
as soon as possible.
263264

264-
> ℹ️ Note: The header `Transfer-Encoding: chunked` will be added once you use
265+
> ℹ️ Note:
266+
> The header `Transfer-Encoding: chunked` will be added once you use
265267
> the trailer. It is a hard requirement for using trailer in Node.js.
266268

267-
> ℹ️ Note: Any error passed to `done` callback will be ignored. If you interested
268-
> in the error, you can turn on `debug` level logging.*
269+
> ℹ️ Note:
270+
> Any error passed to `done` callback will be ignored. If you are interested
271+
> in the error, you can turn on `debug` level logging.
269272

270273
```js
271274
reply.trailer('server-timing', function() {
@@ -315,7 +318,8 @@ reply.getTrailer('server-timing') // undefined
315318
Redirects a request to the specified URL, the status code is optional, default
316319
to `302` (if status code is not already set by calling `code`).
317320

318-
> ℹ️ Note: The input URL must be properly encoded using
321+
> ℹ️ Note:
322+
> The input URL must be properly encoded using
319323
> [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI)
320324
> or similar modules such as
321325
> [`encodeurl`](https://www.npmjs.com/package/encodeurl). Invalid URLs will
@@ -673,7 +677,8 @@ If you pass a string to `send` without a `Content-Type`, it will be sent as
673677
string to `send`, it will be serialized with the custom serializer if one is
674678
set, otherwise, it will be sent unmodified.
675679

676-
> **Note:** Even when the `Content-Type` header is set to `application/json`,
680+
> ℹ️ Note:
681+
> Even when the `Content-Type` header is set to `application/json`,
677682
> strings are sent unmodified by default. To serialize a string as JSON, you
678683
> must set a custom serializer:
679684
@@ -838,7 +843,8 @@ automatically create an error structured as the following:
838843
You can add custom properties to the Error object, such as `headers`, that will
839844
be used to enhance the HTTP response.
840845

841-
> ℹ️ Note: If you are passing an error to `send` and the statusCode is less than
846+
> ℹ️ Note:
847+
> If you are passing an error to `send` and the statusCode is less than
842848
> 400, Fastify will automatically set it at 500.
843849
844850
Tip: you can simplify errors by using the
@@ -886,7 +892,8 @@ fastify.get('/', {
886892
If you want to customize error handling, check out
887893
[`setErrorHandler`](./Server.md#seterrorhandler) API.
888894

889-
> ℹ️ Note: you are responsible for logging when customizing the error handler.
895+
> ℹ️ Note:
896+
> You are responsible for logging when customizing the error handler.
890897
891898
API:
892899

docs/Reference/Request.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Request is a core Fastify object containing the following fields:
2525
enabled). For HTTP/2 compatibility, it returns `:authority` if no host header
2626
exists. The host header may return an empty string if `requireHostHeader` is
2727
`false`, not provided with HTTP/1.0, or removed by schema validation.
28-
Security: this value comes from client-controlled headers; only trust it
28+
⚠ Security: this value comes from client-controlled headers; only trust it
2929
when you control proxy behavior and have validated or allow-listed hosts.
3030
No additional validation is performed beyond RFC parsing (see
3131
[RFC 9110, section 7.2](https://www.rfc-editor.org/rfc/rfc9110#section-7.2) and
@@ -89,7 +89,8 @@ This operation adds new values to the request headers, accessible via
8989
For performance reasons, `Symbol('fastify.RequestAcceptVersion')` may be added
9090
to headers on `not found` routes.
9191

92-
> ℹ️ Note: Schema validation may mutate the `request.headers` and
92+
> ℹ️ Note:
93+
> Schema validation may mutate the `request.headers` and
9394
> `request.raw.headers` objects, causing the headers to become empty.
9495
9596
```js

0 commit comments

Comments
 (0)