Skip to content

Commit e89e91a

Browse files
docs: fix typos (#919)
* docs: Update 1.request.md Typos * chore: apply automated updates * docs: fix typos * chore: apply automated updates --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent f91bbc1 commit e89e91a

File tree

9 files changed

+25
-29
lines changed

9 files changed

+25
-29
lines changed

docs/1.guide/2.event-handler.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ You can define as much middleware as you need. They will be called in order of r
222222
## Converting to h3 handler
223223

224224
There are situations that you might want to convert an event handler or utility made for Node.js or another framework to h3.
225-
There are built-in utils to do this.!
225+
There are built-in utils to do this.
226226

227227
### Converting from Node.js handlers
228228

docs/2.utils/1.request.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default defineEventHandler((event) => {
5353

5454
### `getQuery(event)`
5555

56-
Get query the params object from the request URL parsed with [unjs/ufo](https://ufo.unjs.io).
56+
Get the query params object from the request URL parsed with [unjs/ufo](https://ufo.unjs.io).
5757

5858
**Example:**
5959

@@ -105,11 +105,13 @@ export default defineEventHandler((event) => {
105105
});
106106
```
107107

108-
### `getRequestIP(event)`
108+
### `getRequestIP(event, opts: { xForwardedFor? })`
109109

110110
Try to get the client IP address from the incoming request.
111111

112-
If `xForwardedFor` is `true`, it will use the `x-forwarded-for` header if it exists.
112+
If `xForwardedFor` is `true`, it will use the `x-forwarded-for` header set by proxies if it exists.
113+
114+
Note: Make sure that this header can be trusted (your application running behind a CDN or reverse proxy) before enabling.
113115

114116
If IP cannot be determined, it will default to `undefined`.
115117

@@ -139,7 +141,7 @@ export default defineEventHandler((event) => {
139141

140142
### `getRequestURL(event, opts: { xForwardedHost?, xForwardedProto? })`
141143

142-
Generated the full incoming request URL using `getRequestProtocol`, `getRequestHost` and `event.path`.
144+
Generate the full incoming request URL using `getRequestProtocol`, `getRequestHost` and `event.path`.
143145

144146
If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists.
145147

@@ -183,7 +185,7 @@ export default defineEventHandler((event) => {
183185

184186
### `getValidatedQuery(event, validate)`
185187

186-
Get the query param from the request URL parsed with [unjs/ufo](https://ufo.unjs.io) and validated with validate function.
188+
Get the query params object from the request URL parsed with [unjs/ufo](https://ufo.unjs.io) and validated with validate function.
187189

188190
You can use a simple function to validate the query object or a library like `zod` to define a schema.
189191

@@ -315,7 +317,7 @@ export default defineEventHandler(async (event) => {
315317

316318
### `readMultipartFormData(event)`
317319

318-
Tries to read and parse the body of a an H3Event as multipart form.
320+
Tries to read and parse the body of an H3Event as multipart form.
319321

320322
**Example:**
321323

docs/2.utils/2.response.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Set the response status code and message.
8080

8181
### `getResponseHeader(event, name)`
8282

83-
Alias for `getResponseHeaders`.
83+
Get a response header by name.
8484

8585
**Example:**
8686

@@ -130,7 +130,7 @@ export default defineEventHandler((event) => {
130130

131131
### `isStream(data)`
132132

133-
Checks if the data is a stream. (Node.js Readable Stream, React Pipeable Stream, or Web Stream)
133+
Checks if the data is a stream (Node.js Readable Stream, React Pipeable Stream, or Web Stream).
134134

135135
### `isWebResponse(data)`
136136

@@ -187,7 +187,7 @@ async function delay(ms) {
187187

188188
### `sendNoContent(event, code?)`
189189

190-
Respond with an empty payload.<br>
190+
Respond with an empty payload.
191191

192192
Note that calling this function will close the connection and no other data can be sent to the client afterwards.
193193

docs/2.utils/98.advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Get a cookie value by name.
5050

5151
### `parseCookies(event)`
5252

53-
Parse the request to get HTTP Cookie header string and returning an object of all cookie name-value pairs.
53+
Parse the request to get HTTP Cookie header string and return an object of all cookie name-value pairs.
5454

5555
### `setCookie(event, name, value, serializeOptions?)`
5656

src/utils/body.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export async function readValidatedBody<
219219
}
220220

221221
/**
222-
* Tries to read and parse the body of a an H3Event as multipart form.
222+
* Tries to read and parse the body of an H3Event as multipart form.
223223
*
224224
* @example
225225
* export default defineEventHandler(async (event) => {

src/utils/cookie.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { CookieSerializeOptions } from "cookie-es";
44
import type { H3Event } from "../event";
55

66
/**
7-
* Parse the request to get HTTP Cookie header string and returning an object of all cookie name-value pairs.
7+
* Parse the request to get HTTP Cookie header string and return an object of all cookie name-value pairs.
88
* @param event {H3Event} H3 event or req passed by h3 handler
99
* @returns Object of cookie name-value pairs
1010
* ```ts

src/utils/request.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { validateData, ValidateFunction } from "./internal/validate";
1111
import { getRequestWebStream } from "./body";
1212

1313
/**
14-
* Get query the params object from the request URL parsed with [unjs/ufo](https://ufo.unjs.io).
14+
* Get the query params object from the request URL parsed with [unjs/ufo](https://ufo.unjs.io).
1515
*
1616
* @example
1717
* export default defineEventHandler((event) => {
@@ -27,7 +27,7 @@ export function getQuery<
2727
}
2828

2929
/**
30-
* Get the query param from the request URL parsed with [unjs/ufo](https://ufo.unjs.io) and validated with validate function.
30+
* Get the query params object from the request URL parsed with [unjs/ufo](https://ufo.unjs.io) and validated with validate function.
3131
*
3232
* You can use a simple function to validate the query object or a library like `zod` to define a schema.
3333
*
@@ -319,7 +319,7 @@ export function getRequestPath(event: H3Event): string {
319319
}
320320

321321
/**
322-
* Generated the full incoming request URL using `getRequestProtocol`, `getRequestHost` and `event.path`.
322+
* Generate the full incoming request URL using `getRequestProtocol`, `getRequestHost` and `event.path`.
323323
*
324324
* If `xForwardedHost` is `true`, it will use the `x-forwarded-host` header if it exists.
325325
*
@@ -364,7 +364,9 @@ export function toWebRequest(event: H3Event) {
364364
/**
365365
* Try to get the client IP address from the incoming request.
366366
*
367-
* If `xForwardedFor` is `true`, it will use the `x-forwarded-for` header if it exists.
367+
* If `xForwardedFor` is `true`, it will use the `x-forwarded-for` header set by proxies if it exists.
368+
*
369+
* Note: Make sure that this header can be trusted (your application running behind a CDN or reverse proxy) before enabling.
368370
*
369371
* If IP cannot be determined, it will default to `undefined`.
370372
*
@@ -375,14 +377,7 @@ export function toWebRequest(event: H3Event) {
375377
*/
376378
export function getRequestIP(
377379
event: H3Event,
378-
opts: {
379-
/**
380-
* Use the X-Forwarded-For HTTP header set by proxies.
381-
*
382-
* Note: Make sure that this header can be trusted (your application running behind a CDN or reverse proxy) before enabling.
383-
*/
384-
xForwardedFor?: boolean;
385-
} = {},
380+
opts: { xForwardedFor?: boolean } = {},
386381
): string | undefined {
387382
if (event.context.clientAddress) {
388383
return event.context.clientAddress;

src/utils/response.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function send(
4646
}
4747

4848
/**
49-
* Respond with an empty payload.<br>
49+
* Respond with an empty payload.
5050
*
5151
* Note that calling this function will close the connection and no other data can be sent to the client afterwards.
5252
*
@@ -193,7 +193,7 @@ export function getResponseHeaders(
193193
}
194194

195195
/**
196-
* Alias for `getResponseHeaders`.
196+
* Get a response header by name.
197197
*
198198
* @example
199199
* export default defineEventHandler((event) => {
@@ -355,7 +355,7 @@ export function removeResponseHeader(
355355
}
356356

357357
/**
358-
* Checks if the data is a stream. (Node.js Readable Stream, React Pipeable Stream, or Web Stream)
358+
* Checks if the data is a stream (Node.js Readable Stream, React Pipeable Stream, or Web Stream).
359359
*/
360360
export function isStream(data: any): data is Readable | ReadableStream {
361361
if (!data || typeof data !== "object") {

src/utils/session.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const DEFAULT_COOKIE: SessionConfig["cookie"] = {
4343

4444
/**
4545
* Create a session manager for the current request.
46-
*
4746
*/
4847
export async function useSession<T extends SessionDataT = SessionDataT>(
4948
event: H3Event,

0 commit comments

Comments
 (0)