@nuxt/docs-nightly 5.0.0-29841065.3867d5bc → 5.0.0-29841792.9ceeba8c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,6 @@ This code can run under `@nuxt/nitro-server` and under `@nuxt/vite-server`, and
49
49
  | `getRouteRules` | The [route rules](/docs/guide/concepts/rendering#route-rules) matched for the request. |
50
50
  | `useRuntimeConfig` | The server's [runtime configuration](/docs/guide/going-further/runtime-config). |
51
51
  | `useAppConfig` | The [app config](/docs/directory-structure/app/app-config), as a copy per request when passed the event. |
52
- | `toNuxtRequestEvent` | The event in the shape the server runtime provides. |
53
52
 
54
53
  Types are exported alongside the utilities: `RequestEvent`, `RequestEventContext`, `NuxtRequestEvent`, `EventHandler`, `AppRouteRules`, `ServerRoutes`, `CorsOptions`, `ValidateResult`, `NuxtError`, `NuxtErrorDetails`, `NuxtErrorJSON`, `NuxtErrorLike`, `Session`, `SessionConfig`, `SessionData`, `SessionEvent`, `SessionManager`, `SessionPassword` and `SessionUpdate`.
55
54
 
@@ -83,7 +82,7 @@ export default defineEventHandler(async (event) => {
83
82
  })
84
83
  ```
85
84
 
86
- `NuxtRequestEvent` is the same request in the shape the configured builder provides, which is h3's `H3Event` under `@nuxt/nitro-server`. You can get a type-safe version of the event for the server builder you're using by calling `toNuxtRequestEvent(event)`.
85
+ `NuxtRequestEvent` is the same request in the shape the configured builder provides, which is h3's `H3Event` under `@nuxt/nitro-server`.
87
86
 
88
87
  ## Validation
89
88
 
@@ -167,28 +166,15 @@ export default defineEventHandler(async (event) => {
167
166
 
168
167
  That works for any h3 helper that only reads the request, such as `readRawBody`, `readFormData`, `readMultipartFormData` and `assertMethod`.
169
168
 
170
- A helper that needs the runtime's own event gets it from `toNuxtRequestEvent`:
171
-
172
- ```ts [server/api/proxy.ts]
173
- import { defineEventHandler, toNuxtRequestEvent } from 'nuxt/server'
174
- import { proxyRequest } from 'nitro/h3'
175
-
176
- export default defineEventHandler(event => proxyRequest(toNuxtRequestEvent(event), 'https://example.com'))
177
- ```
178
-
179
- Helpers that need you to call `toNuxtRequestEvent` are `proxy`, `proxyRequest`, `fetchWithEvent`, `writeEarlyHints`, and reading `event.node`, `event.waitUntil()` or `event.runtime`. The helper works on every builder, and a cast to `NuxtRequestEvent` is safe even if the runtime's event is web-shaped, as it is under `@nuxt/nitro-server`.
180
-
181
- Nitro's own APIs mostly take no event at all: `getRouteRules(method, pathname)`, `serverFetch()`, `defineCachedHandler()`, `useStorage()`, `useDatabase()` and tasks.
182
-
183
- ::tip
184
- If you find you are writing Nitro-specific code, you may simply prefer to import `defineEventHandler` from `nitro/h3` instead:
169
+ For a handler that needs the runtime's own event, such as one calling `proxy`, `proxyRequest`, `fetchWithEvent` or `writeEarlyHints`, or reading `event.node`, `event.waitUntil()` or `event.runtime`, import `defineEventHandler` from `nitro/h3` for that handler:
185
170
 
186
171
  ```ts [server/api/proxy.ts]
187
172
  import { defineEventHandler, proxyRequest } from 'nitro/h3'
188
173
 
189
174
  export default defineEventHandler(event => proxyRequest(event, 'https://example.com'))
190
175
  ```
191
- ::
176
+
177
+ Nitro's own APIs mostly take no event at all: `getRouteRules(method, pathname)`, `serverFetch()`, `defineCachedHandler()`, `useStorage()`, `useDatabase()` and tasks.
192
178
 
193
179
  ## What Isn't Portable
194
180
 
@@ -330,7 +330,7 @@ One of the modules in the list is `nuxt/server`, the set of [server imports](/do
330
330
 
331
331
  By default, `nuxt/server` will resolve to the web-standard implementations Nuxt ships. They're written against the `RequestEvent` shape, and they're what `@nuxt/vite-server` runs on.
332
332
 
333
- Whatever event you pass to a handler must match `RequestEvent`. Register your event's type in the `ServerTypes` registry in `@nuxt/schema`, which is what `NuxtRequestEvent` and `useRequestEvent()` resolve to. If your own event object isn't web-shaped, pass handlers a web-shaped view of it (`toNuxtRequestEvent()` returns one) and put your own event on the `~app` property, so `useRequestEvent()` and the render hooks give app code your event instead.
333
+ Whatever event you pass to a handler must match `RequestEvent`. Register your event's type in the `ServerTypes` registry in `@nuxt/schema`, which is what `NuxtRequestEvent` and `useRequestEvent()` resolve to. If your own event object isn't web-shaped, pass handlers a web-shaped view of it. To give app code your own event instead, set it as `~app` on the event you pass the [renderer](#standing-up-the-ssr-renderer).
334
334
 
335
335
  If your runtime can implement some of these better than the shipped versions, point Nuxt at your own module:
336
336
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs-nightly",
3
- "version": "5.0.0-29841065.3867d5bc",
3
+ "version": "5.0.0-29841792.9ceeba8c",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",