mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
This updates our logging to use Error objects to provide stacks to better locate where sync access of Request APIs is happening
32 lines
837 B
TypeScript
32 lines
837 B
TypeScript
import { type NextRequest } from 'next/server'
|
|
import { withRequestMeta } from '../helpers'
|
|
|
|
const helloHandler = async (
|
|
request: NextRequest,
|
|
{ params }: { params?: Promise<Record<string, string | string[]>> }
|
|
): Promise<Response> => {
|
|
const { pathname } = request.nextUrl
|
|
|
|
if (typeof WebSocket === 'undefined') {
|
|
throw new Error('missing WebSocket constructor!!')
|
|
}
|
|
|
|
const resolvedParams = params ? await params : null
|
|
|
|
return new Response('hello, world', {
|
|
headers: withRequestMeta({
|
|
method: request.method,
|
|
params: resolvedParams,
|
|
pathname,
|
|
}),
|
|
})
|
|
}
|
|
|
|
export const GET = helloHandler
|
|
export const HEAD = helloHandler
|
|
export const OPTIONS = helloHandler
|
|
export const POST = helloHandler
|
|
export const PUT = helloHandler
|
|
export const DELETE = helloHandler
|
|
export const PATCH = helloHandler
|