Skip to content

Commit

Permalink
docs: fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrentz committed Nov 25, 2024
1 parent b0bc96b commit 64a6d3b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/1.guide/2.event-handler.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ You can define as much middleware as you need. They will be called in order of r
## Converting to h3 handler

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

### Converting from Node.js handlers

Expand Down
2 changes: 1 addition & 1 deletion src/utils/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export async function readValidatedBody<
}

/**
* 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
* export default defineEventHandler(async (event) => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { CookieSerializeOptions } from "cookie-es";
import type { H3Event } from "../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.
* @param event {H3Event} H3 event or req passed by h3 handler
* @returns Object of cookie name-value pairs
* ```ts
Expand Down
19 changes: 7 additions & 12 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { validateData, ValidateFunction } from "./internal/validate";
import { getRequestWebStream } from "./body";

/**
* 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
* export default defineEventHandler((event) => {
Expand All @@ -27,7 +27,7 @@ export function getQuery<
}

/**
* 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 @@ -319,7 +319,7 @@ export function getRequestPath(event: H3Event): string {
}

/**
* 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 @@ -364,7 +364,9 @@ export function toWebRequest(event: H3Event) {
/**
* 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 All @@ -375,14 +377,7 @@ export function toWebRequest(event: H3Event) {
*/
export function getRequestIP(
event: H3Event,
opts: {
/**
* Use the X-Forwarded-For HTTP header set by proxies.
*
* Note: Make sure that this header can be trusted (your application running behind a CDN or reverse proxy) before enabling.
*/
xForwardedFor?: boolean;
} = {},
opts: { xForwardedFor?: boolean; } = {},
): string | undefined {
if (event.context.clientAddress) {
return event.context.clientAddress;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function send(
}

/**
* 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 Expand Up @@ -193,7 +193,7 @@ export function getResponseHeaders(
}

/**
* Alias for `getResponseHeaders`.
* Get a response header by name.
*
* @example
* export default defineEventHandler((event) => {
Expand Down Expand Up @@ -355,7 +355,7 @@ export function removeResponseHeader(
}

/**
* 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).
*/
export function isStream(data: any): data is Readable | ReadableStream {
if (!data || typeof data !== "object") {
Expand Down
1 change: 0 additions & 1 deletion src/utils/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const DEFAULT_COOKIE: SessionConfig["cookie"] = {

/**
* Create a session manager for the current request.
*
*/
export async function useSession<T extends SessionDataT = SessionDataT>(
event: H3Event,
Expand Down

0 comments on commit 64a6d3b

Please sign in to comment.