diff --git a/banner-dark.png b/banner-dark.png index dd1fb26b..70a6f77a 100644 Binary files a/banner-dark.png and b/banner-dark.png differ diff --git a/banner.png b/banner.png index f57b0f66..2e1d3f94 100644 Binary files a/banner.png and b/banner.png differ diff --git a/docs/content/docs/concepts/plugins.mdx b/docs/content/docs/concepts/plugins.mdx index d94a094b..0b035e08 100644 --- a/docs/content/docs/concepts/plugins.mdx +++ b/docs/content/docs/concepts/plugins.mdx @@ -190,16 +190,14 @@ If you throw an `APIError` from the middleware or returned a `Response` object, Additional to middlewares you can also hook into right before a request is made and right after a response is returned. This is mostly useful if you wnat to do something that affects all requests or responses. -### On Request +#### On Request The `onRequest` function is called right before the request is made. It takes two parameters: the `request` and the `context` object. Here’s how it works: - **Continue as Normal**: If you don't return anything, the request will proceed as usual. - - **Interrupt the Request**: To stop the request and send a response, return an object with a `response` property that contains a `Response` object. - - **Modify the Request**: You can also return a modified `request` object to change the request before it's sent. ```ts title="plugin.ts" @@ -211,14 +209,13 @@ const myPlugin = { } ``` -### On Response +#### On Response The `onResponse` function is executed immediately after a response is returned. It takes two parameters: the `response` and the `context` object. Here’s how to use it: - **Modify the Response**: You can return a modified response object to change the response before it is sent to the client. - - **Continue Normally**: If you don’t return anything, the response will be sent as is. ```ts title="plugin.ts" @@ -268,9 +265,7 @@ const myPlugin = { #### When to use Middelware, Hooks, On Request, On Response - **Middlewares**: You should use middlewares when you want to use a route matcher to target a group of routes. - - **Hooks**: You should use hooks when you want to target a specific route or request. - - **On Request & On Response**: You should use on request and on response when you want to do something that affects all requests or responses. ### Rate Limit