rsnext/test/e2e/app-dir/app-routes-trailing-slash/app/runtime
Wyatt Johnson 1fbbba6ffe
Unify Request types (#47884)
This serves to start the transition of replacing the following:

- Replace `BaseNextRequest`, `WebNextRequest`, and `NodeNextRequest`
with `NextRequest`
- Replace `BaseNextResponse`, `WebNextResponse`, and `NodeNextResponse`
with `Response`

This will currently only apply to app routes, enabling the following:

```ts
////////////////////////////////////////////////////////////////////////////////
// Use `Request` and `Response`
////////////////////////////////////////////////////////////////////////////////

import { NextRequest, NextResponse } from 'next/server'

export function GET(request: Request): Response {
  return new Response(
    JSON.stringify({
      hello: request.headers.get('user-agent'),
    }),
    { headers: { 'content-type': 'application/json' } }
  )
}

////////////////////////////////////////////////////////////////////////////////
// Use `NextRequest` and `NextResponse`
////////////////////////////////////////////////////////////////////////////////

import { NextRequest, NextResponse } from 'next/server'

export function GET(request: NextRequest): NextResponse {
  return NextResponse.json({ hello: request.headers.get('user-agent') })
}

////////////////////////////////////////////////////////////////////////////////
// Use `NextRequest` and `Response`
////////////////////////////////////////////////////////////////////////////////

import { NextRequest, NextResponse } from 'next/server'

// `NextRequest` extends `Request`.
export function GET(request: NextRequest): Response {
  return new Response(
    JSON.stringify({ hello: request.headers.get('user-agent') }),
    { headers: { 'content-type': 'application/json' } }
  )
}

////////////////////////////////////////////////////////////////////////////////
// Use `NextRequest`, `NextResponse`, and `Response`
////////////////////////////////////////////////////////////////////////////////

import { NextRequest, NextResponse } from 'next/server'

export function GET(request: NextRequest): Response {
  // `NextResponse` extends `Response`.
  return NextResponse.json({ hello: request.headers.get('user-agent') })
}

////////////////////////////////////////////////////////////////////////////////
// Use `Request` and `NextResponse`
////////////////////////////////////////////////////////////////////////////////

import { NextRequest, NextResponse } from 'next/server'

export function GET(request: Request): NextResponse {
  return NextResponse.json({ hello: request.headers.get('user-agent') })
}

```

fix NEXT-713
2023-04-05 18:24:08 +00:00
..
edge Unify Request types (#47884) 2023-04-05 18:24:08 +00:00
node Unify Request types (#47884) 2023-04-05 18:24:08 +00:00