rsnext/test
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
..
.stats-app Remove serverComponents from next.conf.js because it's unused (#43805) 2022-12-07 15:57:03 +01:00
__mocks__ Update Edge Runtime (#38862) 2022-07-21 18:29:19 +00:00
development Auto-restart dev server when next.config.js changes (#47912) 2023-04-05 18:17:54 +00:00
e2e Unify Request types (#47884) 2023-04-05 18:24:08 +00:00
examples feat(cli): introduce --tailwind flag (#46927) 2023-03-16 16:06:27 +01:00
integration Add strict next head handling (#47938) 2023-04-05 08:29:36 +00:00
lib Auto-restart dev server when next.config.js changes (#47912) 2023-04-05 18:17:54 +00:00
production Add initial separated route resolving (#47208) 2023-04-02 15:17:15 +02:00
unit (Fix)(Tests)Fix typo in unit testing (#47644) 2023-04-01 22:23:15 -07:00
.gitignore Fix server html insertion target (#42591) 2022-11-07 18:16:13 +01:00
jest-setup-after-env.ts Increase CI test timeout (#47973) 2023-04-05 10:16:48 -07:00
jest.d.ts Adds tests to ensure eslint-plugin-next's available rules are properly exported and recommended rules are correctly defined. (#38183) 2022-06-30 11:31:33 -05:00
readme.md refactor: split up CONTRIBUTING.md (#40515) 2022-09-16 14:54:58 -07:00
test-file.txt

See Testing for more information on how you can run/write/debug tests for Next.js.