next.js/test/e2e/app-dir/use-cache-route-handler-only/app/node-dynamic/route.ts
route.ts20 lines374 B
import { connection } from 'next/server'
import { setTimeout } from 'timers/promises'

async function getCachedRandom() {
  'use cache'

  // Simulate I/O latency so concurrent requests overlap.
  await setTimeout(1000)

  return Math.random()
}

export async function GET() {
  await connection()

  const rand = await getCachedRandom()

  return Response.json({ rand })
}
Quest for Codev2.0.0
/
SIGN IN