Declaring the edge runtime for a route moves it to a V8 isolate that exposes Web APIs such as fetch, Request, Response, the Web Crypto subtle interface and TextEncoder, but not fs, net, child_process, native addons, or most Node built-ins. The build fails with a module-not-found for fs, or warns that an unsupported Node.js API is used in the Edge Runtime.
Anything that reads files at runtime, opens a raw TCP connection to a database, or depends on a native binary must run on the Node.js runtime.
The practical split is to use edge for auth checks, redirects, header rewriting and streaming proxies, and Node for database access unless the driver speaks HTTP. Middleware always runs in the Edge runtime, which is why importing a Postgres client into middleware breaks the build even though the identical import works in a route handler two directories away.