Direct SDK Import in Route Handler
highAPIImporting database SDKs directly in route handlers creates tight coupling and makes testing difficult.
import { createClient } from '@supabase/supabase-js';
// dead-export-exempt: test-only-consumer
export async function GET() {
const supabase = createClient(url, key);
const { data } = await supabase.from('users').select('*');
return Response.json(data);
}import { getUsers } from '@/lib/supabase/users';
export async function GET() {
const data = await getUsers();
return Response.json(data);
}Why this matters: The adapter pattern isolates vendor dependencies. If you switch databases, only the adapter changes — not every route handler.