next.js/test/e2e/app-dir/app-routes/app/top-level-await/route.ts
route.ts10 lines430 B
// This route uses a top-level await to simulate an async module (e.g. a route
// that fetches config or initializes a DB connection at module load time).
// require() returns a Promise for such modules, so the route module must not
// eagerly call _initFromUserland() before the Promise resolves.
const message = await Promise.resolve('hello from top-level await')

export async function GET() {
  return new Response(message)
}
Quest for Codev2.0.0
/
SIGN IN