Skip to content

Commit

Permalink
chore: apply automated updates
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Nov 25, 2024
1 parent 64a6d3b commit c6b0e09
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions docs/2.utils/1.request.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default defineEventHandler((event) => {

### `getQuery(event)`

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

**Example:**

Expand Down Expand Up @@ -105,11 +105,13 @@ export default defineEventHandler((event) => {
});
```

### `getRequestIP(event)`
### `getRequestIP(event, opts: { xForwardedFor? })`

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

If `xForwardedFor` is `true`, it will use the `x-forwarded-for` header if it exists.
If `xForwardedFor` is `true`, it will use the `x-forwarded-for` header set by proxies if it exists.

Note: Make sure that this header can be trusted (your application running behind a CDN or reverse proxy) before enabling.

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

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

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

Generated the full incoming request URL using `getRequestProtocol`, `getRequestHost` and `event.path`.
Generate the full incoming request URL using `getRequestProtocol`, `getRequestHost` and `event.path`.

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

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

### `getValidatedQuery(event, validate)`

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

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

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

### `readMultipartFormData(event)`

Tries to read and parse the body of a an H3Event as multipart form.
Tries to read and parse the body of an H3Event as multipart form.

**Example:**

Expand Down
6 changes: 3 additions & 3 deletions docs/2.utils/2.response.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Set the response status code and message.

### `getResponseHeader(event, name)`

Alias for `getResponseHeaders`.
Get a response header by name.

**Example:**

Expand Down Expand Up @@ -130,7 +130,7 @@ export default defineEventHandler((event) => {

### `isStream(data)`

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

### `isWebResponse(data)`

Expand Down Expand Up @@ -187,7 +187,7 @@ async function delay(ms) {

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

Respond with an empty payload.<br>
Respond with an empty payload.

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

Expand Down
2 changes: 1 addition & 1 deletion docs/2.utils/98.advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Get a cookie value by name.

### `parseCookies(event)`

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ export function toWebRequest(event: H3Event) {
*/
export function getRequestIP(
event: H3Event,
opts: { xForwardedFor?: boolean; } = {},
opts: { xForwardedFor?: boolean } = {},
): string | undefined {
if (event.context.clientAddress) {
return event.context.clientAddress;
Expand Down

0 comments on commit c6b0e09

Please sign in to comment.