From 08e2cb83b5c37b4e55258c21e0f5aac8a2467372 Mon Sep 17 00:00:00 2001 From: barisgit Date: Thu, 24 Apr 2025 21:51:27 +0200 Subject: [PATCH 1/6] Fix main page and connection pool --- apps/web/src/app/page.tsx | 5 ++--- packages/db/src/index.ts | 32 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsx index a98afe1..e4522f5 100644 --- a/apps/web/src/app/page.tsx +++ b/apps/web/src/app/page.tsx @@ -10,9 +10,8 @@ import { WikiFolderTree } from "~/components/wiki/WikiFolderTree"; import { getServerSession } from "next-auth/next"; import { authOptions } from "~/lib/auth"; -export const revalidate = 300; // Revalidate every 5 minutes -export const fetchCache = "force-cache"; -export const dynamic = "auto"; +export const revalidate = 900; // Revalidate every 15 minutes +export const dynamic = "force-static"; export default async function Home() { const recentPages = await dbService.wiki.getRecentPages(5); diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 4bb179a..6d9d647 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -48,34 +48,40 @@ if (vercelPostgresUrl) { neonConfig.fetchConnectionCache = true; const sql = neon(databaseUrl); db = drizzleNeon(sql, { schema }); -} else if (runningOnVercel) { - // --- Priority 3: On Vercel, but NOT using Vercel's integrated DB or Neon. --- - // USE STANDARD pg.Pool. This simplifies setup but RISKS connection limits on Vercel. - // User MUST ensure their DB can handle potential connections from many function instances by eg. providing a PgBouncer or other pooler. +} else if (runningOnVercel && databaseUrl) { + // --- Priority 3: On Vercel, NOT using Vercel PG or Neon. Using external DB (likely via PgBouncer). --- + // Use Vercel's pool utility even with a standard DATABASE_URL. + // This is generally better suited for the serverless environment than pg.Pool. console.warn( - "WARNING: Running on Vercel without Vercel Postgres or Neon DB. Using standard pg.Pool (DATABASE_URL)." + "WARNING: Running on Vercel with external DATABASE_URL. Using Vercel/Postgres driver." ); console.warn( - "Ensure your database connection limit is high enough for potential Vercel scaling or that you have a PgBouncer or other pooler!" + "Ensure your DATABASE_URL points to a pooler (like PgBouncer) capable of handling Vercel scaling!" ); - const poolSize = 3; // Keep pool size very small for Vercel fallback - const pool = new pg.Pool({ - connectionString: databaseUrl, - max: poolSize, - }); - db = drizzlePg(pool, { schema }); -} else { + // Let createVercelPool manage the connections suitable for serverless. + const vercelPool = createVercelPool({ connectionString: databaseUrl }); + db = drizzleVercel(vercelPool, { schema }); +} else if (databaseUrl) { // --- Priority 4: Standard/Local setup (Not on Vercel, Not Neon) --- // Use the standard node-postgres pool. console.log( "Using standard PostgreSQL driver (pg.Pool) with DATABASE_URL (Not on Vercel/Neon)" ); + // const poolSize = process.env.DATABASE_POOL_SIZE + // ? parseInt(process.env.DATABASE_POOL_SIZE, 10) + // : 10; // Default pool size const poolSize = 10; + console.log(`Using pg.Pool with pool size: ${poolSize}`); const pool = new pg.Pool({ connectionString: databaseUrl, // Use the main DATABASE_URL max: poolSize, }); db = drizzlePg(pool, { schema }); +} else { + // This case should theoretically not be reached due to the initial check, + // but provides a fallback / clear error if logic changes. + console.error("Could not determine database connection method."); + throw new Error("Invalid database configuration state."); } // Export the configured db From f61291687d751cccec3bcd87b67387622fdf40ac Mon Sep 17 00:00:00 2001 From: barisgit Date: Thu, 24 Apr 2025 21:55:11 +0200 Subject: [PATCH 2/6] Use vercel pooler workaround --- packages/db/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 6d9d647..070e436 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -59,7 +59,9 @@ if (vercelPostgresUrl) { "Ensure your DATABASE_URL points to a pooler (like PgBouncer) capable of handling Vercel scaling!" ); // Let createVercelPool manage the connections suitable for serverless. - const vercelPool = createVercelPool({ connectionString: databaseUrl }); + const vercelPool = createVercelPool({ + connectionString: databaseUrl + "?pooler.", + }); db = drizzleVercel(vercelPool, { schema }); } else if (databaseUrl) { // --- Priority 4: Standard/Local setup (Not on Vercel, Not Neon) --- From a5851f70a1e04e356d99b048c8d6cc1d351be0e9 Mon Sep 17 00:00:00 2001 From: barisgit Date: Thu, 24 Apr 2025 21:58:06 +0200 Subject: [PATCH 3/6] Fixed wrong thing --- packages/db/src/index.ts | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 070e436..a5b463d 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -39,8 +39,25 @@ let db: DatabaseType; // Determine which driver to use based on priority if (vercelPostgresUrl) { // --- Priority 1: Using Vercel's integrated Postgres service --- + // OR using Supabase/external pooler identified via POSTGRES_URL console.log("Using Vercel Postgres driver (POSTGRES_URL detected)"); - const vercelPool = createVercelPool({ connectionString: vercelPostgresUrl }); + // Apply workaround for non-Vercel pooled URLs (like Supabase) that don't match the expected pattern + // Check if 'pooler' (common in Supabase/PgBouncer URLs) or '?pooler=' (the workaround) is present. + const needsWorkaround = !/pooler/i.test(vercelPostgresUrl); + const effectiveConnectionString = needsWorkaround + ? vercelPostgresUrl + "?pooler." + : vercelPostgresUrl; + + if (needsWorkaround) { + console.warn( + "Applied '?pooler.' suffix workaround for potential non-Vercel pooler URL in POSTGRES_URL." + ); + } + // console.log(`Effective connection string: ${effectiveConnectionString}`); // Optional: uncomment for debugging + + const vercelPool = createVercelPool({ + connectionString: effectiveConnectionString, + }); db = drizzleVercel(vercelPool, { schema }); } else if (databaseUrl && databaseUrl.includes(".neon.tech")) { // --- Priority 2: Using Neon DB (checked via DATABASE_URL) --- @@ -59,8 +76,21 @@ if (vercelPostgresUrl) { "Ensure your DATABASE_URL points to a pooler (like PgBouncer) capable of handling Vercel scaling!" ); // Let createVercelPool manage the connections suitable for serverless. + // Apply the same workaround check here for consistency + const needsWorkaround = !/pooler/i.test(databaseUrl); + const effectiveConnectionString = needsWorkaround + ? databaseUrl + "?pooler." + : databaseUrl; + + if (needsWorkaround) { + console.warn( + "Applied '?pooler.' suffix workaround for potential non-Vercel pooler URL in DATABASE_URL on Vercel." + ); + } + // console.log(`Effective connection string: ${effectiveConnectionString}`); // Optional: uncomment for debugging + const vercelPool = createVercelPool({ - connectionString: databaseUrl + "?pooler.", + connectionString: effectiveConnectionString, }); db = drizzleVercel(vercelPool, { schema }); } else if (databaseUrl) { From e519dc471d931d079ede81918a0b32ca73fad333 Mon Sep 17 00:00:00 2001 From: barisgit Date: Thu, 24 Apr 2025 22:08:15 +0200 Subject: [PATCH 4/6] Use simple client if we have external pooler --- packages/db/src/index.ts | 54 +++++++++++++--------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index a5b463d..80ea380 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -7,8 +7,12 @@ import type { NodePgDatabase } from "drizzle-orm/node-postgres"; import { drizzle as drizzleVercel, type VercelPgDatabase, + type VercelPgClient, } from "drizzle-orm/vercel-postgres"; -import { createPool as createVercelPool } from "@vercel/postgres"; +import { + createClient as createVercelClient, + createPool as createVercelPool, +} from "@vercel/postgres"; import pg from "pg"; import * as schema from "./schema/index.js"; @@ -18,7 +22,8 @@ dotenv.config({ path: [".env.local", ".env"] }); // Define environment variables we check const databaseUrl = process.env.DATABASE_URL; const vercelPostgresUrl = process.env.POSTGRES_URL; // Vercel's own managed DB -const runningOnVercel = !!process.env.VERCEL; +// const runningOnVercel = !!process.env.VERCEL; +const runningOnVercel = true; // Validate *at least* DATABASE_URL is set (needed as fallback or for non-Vercel/non-Neon) if (!databaseUrl && !vercelPostgresUrl) { @@ -40,24 +45,9 @@ let db: DatabaseType; if (vercelPostgresUrl) { // --- Priority 1: Using Vercel's integrated Postgres service --- // OR using Supabase/external pooler identified via POSTGRES_URL - console.log("Using Vercel Postgres driver (POSTGRES_URL detected)"); - // Apply workaround for non-Vercel pooled URLs (like Supabase) that don't match the expected pattern - // Check if 'pooler' (common in Supabase/PgBouncer URLs) or '?pooler=' (the workaround) is present. - const needsWorkaround = !/pooler/i.test(vercelPostgresUrl); - const effectiveConnectionString = needsWorkaround - ? vercelPostgresUrl + "?pooler." - : vercelPostgresUrl; - - if (needsWorkaround) { - console.warn( - "Applied '?pooler.' suffix workaround for potential non-Vercel pooler URL in POSTGRES_URL." - ); - } - // console.log(`Effective connection string: ${effectiveConnectionString}`); // Optional: uncomment for debugging - - const vercelPool = createVercelPool({ - connectionString: effectiveConnectionString, - }); + console.log("Using Vercel Postgres pool driver (POSTGRES_URL detected)"); + // Use createPool as recommended for Vercel's own Postgres + const vercelPool = createVercelPool({ connectionString: vercelPostgresUrl }); db = drizzleVercel(vercelPool, { schema }); } else if (databaseUrl && databaseUrl.includes(".neon.tech")) { // --- Priority 2: Using Neon DB (checked via DATABASE_URL) --- @@ -75,24 +65,14 @@ if (vercelPostgresUrl) { console.warn( "Ensure your DATABASE_URL points to a pooler (like PgBouncer) capable of handling Vercel scaling!" ); - // Let createVercelPool manage the connections suitable for serverless. - // Apply the same workaround check here for consistency - const needsWorkaround = !/pooler/i.test(databaseUrl); - const effectiveConnectionString = needsWorkaround - ? databaseUrl + "?pooler." - : databaseUrl; - - if (needsWorkaround) { - console.warn( - "Applied '?pooler.' suffix workaround for potential non-Vercel pooler URL in DATABASE_URL on Vercel." - ); - } - // console.log(`Effective connection string: ${effectiveConnectionString}`); // Optional: uncomment for debugging - - const vercelPool = createVercelPool({ - connectionString: effectiveConnectionString, + // Keep using createClient here for external DBs on Vercel, as pool had issues + console.warn( + "Using createClient with external DATABASE_URL on Vercel. This might bypass pooler issues but could exhaust connections." + ); + const vercelClient: VercelPgClient = createVercelClient({ + connectionString: databaseUrl, }); - db = drizzleVercel(vercelPool, { schema }); + db = drizzleVercel(vercelClient, { schema }); } else if (databaseUrl) { // --- Priority 4: Standard/Local setup (Not on Vercel, Not Neon) --- // Use the standard node-postgres pool. From 4841e49062bd40a213e2b2e6d15c28eb1a771a5f Mon Sep 17 00:00:00 2001 From: barisgit Date: Thu, 24 Apr 2025 22:35:43 +0200 Subject: [PATCH 5/6] Refactor connection handling to be much more readable and reliable --- packages/db/src/index.ts | 183 +++++++++++++++++++++++++-------------- 1 file changed, 119 insertions(+), 64 deletions(-) diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 80ea380..5a4caa5 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -7,25 +7,63 @@ import type { NodePgDatabase } from "drizzle-orm/node-postgres"; import { drizzle as drizzleVercel, type VercelPgDatabase, - type VercelPgClient, } from "drizzle-orm/vercel-postgres"; -import { - createClient as createVercelClient, - createPool as createVercelPool, -} from "@vercel/postgres"; +import { createPool as createVercelPool } from "@vercel/postgres"; import pg from "pg"; import * as schema from "./schema/index.js"; +import { logger } from "@repo/logger"; // Load environment variables from .env file if present dotenv.config({ path: [".env.local", ".env"] }); +// --- Configuration --- + // Define environment variables we check const databaseUrl = process.env.DATABASE_URL; const vercelPostgresUrl = process.env.POSTGRES_URL; // Vercel's own managed DB -// const runningOnVercel = !!process.env.VERCEL; -const runningOnVercel = true; +const runningOnVercel = !!process.env.VERCEL; + +/** + * Enum representing the different database connection types. + */ +export enum ConnectionType { + VERCEL_POSTGRES = "VERCEL_POSTGRES", // Vercel's managed Postgres or external pooler via POSTGRES_URL + NEON = "NEON", // Neon DB via DATABASE_URL + VERCEL_EXTERNAL_POOL = "VERCEL_EXTERNAL_POOL", // External DB on Vercel via DATABASE_URL (e.g., PgBouncer) + STANDARD_POOL = "STANDARD_POOL", // Standard node-postgres pool (local/non-Vercel) + INVALID = "INVALID", // Configuration is invalid +} + +/** + * Determines the database connection type based on environment variables. + * @param dbUrl - The DATABASE_URL environment variable. + * @param vercelUrl - The POSTGRES_URL environment variable. + * @param isOnVercel - Boolean indicating if running on Vercel. + * @returns The determined ConnectionType. + */ +const getConnectionType = ( + dbUrl: string | undefined, + vercelUrl: string | undefined, + isOnVercel: boolean +): ConnectionType => { + if (vercelUrl) { + return ConnectionType.VERCEL_POSTGRES; + } + if (dbUrl && dbUrl.includes(".neon.tech")) { + return ConnectionType.NEON; + } + if (isOnVercel && dbUrl) { + return ConnectionType.VERCEL_EXTERNAL_POOL; + } + if (dbUrl) { + return ConnectionType.STANDARD_POOL; + } + return ConnectionType.INVALID; +}; -// Validate *at least* DATABASE_URL is set (needed as fallback or for non-Vercel/non-Neon) +// --- Database Initialization --- + +// Validate *at least* one URL is set if (!databaseUrl && !vercelPostgresUrl) { console.error("At least one of DATABASE_URL or POSTGRES_URL must be set!"); throw new Error( @@ -35,68 +73,85 @@ if (!databaseUrl && !vercelPostgresUrl) { // Define a union type for all possible database types export type DatabaseType = - | VercelPgDatabase // Used for Vercel managed DB OR Vercel deployment with external pooler + | VercelPgDatabase | NeonHttpDatabase - | NodePgDatabase; // Used for local/standard non-Vercel hosting + | NodePgDatabase; let db: DatabaseType; +const connectionType = getConnectionType( + databaseUrl, + vercelPostgresUrl, + runningOnVercel +); -// Determine which driver to use based on priority -if (vercelPostgresUrl) { - // --- Priority 1: Using Vercel's integrated Postgres service --- - // OR using Supabase/external pooler identified via POSTGRES_URL - console.log("Using Vercel Postgres pool driver (POSTGRES_URL detected)"); - // Use createPool as recommended for Vercel's own Postgres - const vercelPool = createVercelPool({ connectionString: vercelPostgresUrl }); - db = drizzleVercel(vercelPool, { schema }); -} else if (databaseUrl && databaseUrl.includes(".neon.tech")) { - // --- Priority 2: Using Neon DB (checked via DATABASE_URL) --- - console.log("Using Neon database driver (DATABASE_URL contains .neon.tech)"); - neonConfig.fetchConnectionCache = true; - const sql = neon(databaseUrl); - db = drizzleNeon(sql, { schema }); -} else if (runningOnVercel && databaseUrl) { - // --- Priority 3: On Vercel, NOT using Vercel PG or Neon. Using external DB (likely via PgBouncer). --- - // Use Vercel's pool utility even with a standard DATABASE_URL. - // This is generally better suited for the serverless environment than pg.Pool. - console.warn( - "WARNING: Running on Vercel with external DATABASE_URL. Using Vercel/Postgres driver." - ); - console.warn( - "Ensure your DATABASE_URL points to a pooler (like PgBouncer) capable of handling Vercel scaling!" - ); - // Keep using createClient here for external DBs on Vercel, as pool had issues - console.warn( - "Using createClient with external DATABASE_URL on Vercel. This might bypass pooler issues but could exhaust connections." - ); - const vercelClient: VercelPgClient = createVercelClient({ - connectionString: databaseUrl, - }); - db = drizzleVercel(vercelClient, { schema }); -} else if (databaseUrl) { - // --- Priority 4: Standard/Local setup (Not on Vercel, Not Neon) --- - // Use the standard node-postgres pool. - console.log( - "Using standard PostgreSQL driver (pg.Pool) with DATABASE_URL (Not on Vercel/Neon)" - ); - // const poolSize = process.env.DATABASE_POOL_SIZE - // ? parseInt(process.env.DATABASE_POOL_SIZE, 10) - // : 10; // Default pool size - const poolSize = 10; - console.log(`Using pg.Pool with pool size: ${poolSize}`); - const pool = new pg.Pool({ - connectionString: databaseUrl, // Use the main DATABASE_URL - max: poolSize, - }); - db = drizzlePg(pool, { schema }); -} else { - // This case should theoretically not be reached due to the initial check, - // but provides a fallback / clear error if logic changes. - console.error("Could not determine database connection method."); - throw new Error("Invalid database configuration state."); +// const poolSize = process.env.DATABASE_POOL_SIZE +// ? parseInt(process.env.DATABASE_POOL_SIZE, 10) +// : 10; + +const poolSize = 10; + +switch (connectionType) { + case ConnectionType.VERCEL_POSTGRES: + console.log("Using Vercel Postgres pool driver (POSTGRES_URL detected)"); + // Use createPool as recommended for Vercel's own Postgres + // We know vercelPostgresUrl is defined here due to getConnectionType logic + db = drizzleVercel( + createVercelPool({ + connectionString: vercelPostgresUrl!, + }), + { schema } + ); + break; + + case ConnectionType.NEON: + console.log( + "Using Neon database driver (DATABASE_URL contains .neon.tech)" + ); + // We know databaseUrl is defined here due to getConnectionType logic + neonConfig.fetchConnectionCache = true; + db = drizzleNeon(neon(databaseUrl!), { schema }); + break; + + case ConnectionType.VERCEL_EXTERNAL_POOL: + console.warn( + "Using standard pg.Pool with external DATABASE_URL on Vercel. Ensure the URL points to a pooler." + ); + // We know databaseUrl is defined here due to getConnectionType logic + db = drizzlePg( + new pg.Pool({ + connectionString: databaseUrl!, + max: 1, // Recommended for Vercel serverless functions connecting to external DBs + }), + { schema } + ); + break; + + case ConnectionType.STANDARD_POOL: + console.log( + "Using standard PostgreSQL driver (pg.Pool) with DATABASE_URL (Not on Vercel/Neon)" + ); + // We know databaseUrl is defined here due to getConnectionType logic + console.log(`Using pg.Pool with pool size: ${poolSize}`); + db = drizzlePg( + new pg.Pool({ + connectionString: databaseUrl!, + max: poolSize, + }), + { schema } + ); + break; + + case ConnectionType.INVALID: + default: + // This case should theoretically not be reached due to the initial validation + // and the logic in getConnectionType, but it's good practice to handle it. + logger.error("Could not determine database connection method."); + throw new Error("Invalid database configuration state."); } -// Export the configured db +// --- Exports --- + +// Export the configured db as a named export export { db }; // Re-export the seed function From 65b679cfde2d466ba901307e077767131087e6ea Mon Sep 17 00:00:00 2001 From: barisgit Date: Thu, 24 Apr 2025 23:56:12 +0200 Subject: [PATCH 6/6] Database connection finalization --- apps/web/src/app/(auth)/login/login-page.tsx | 54 -------------------- apps/web/src/app/api/[404]/route.ts | 2 + packages/db/src/index.ts | 15 +++--- 3 files changed, 10 insertions(+), 61 deletions(-) delete mode 100644 apps/web/src/app/(auth)/login/login-page.tsx diff --git a/apps/web/src/app/(auth)/login/login-page.tsx b/apps/web/src/app/(auth)/login/login-page.tsx deleted file mode 100644 index afe9c2b..0000000 --- a/apps/web/src/app/(auth)/login/login-page.tsx +++ /dev/null @@ -1,54 +0,0 @@ -"use client"; - -import { LoginForm } from "~/components/auth/LoginForm"; -import { Suspense, useEffect } from "react"; -import { useRouter } from "next/navigation"; -import { usePermissions } from "~/components/auth/permission/client"; -import { Button } from "@repo/ui"; -import { ArrowLeftIcon } from "lucide-react"; - -export default function LoginPage() { - const router = useRouter(); - const { isAuthenticated, hasPermission } = usePermissions(); - - useEffect(() => { - if (isAuthenticated) { - router.push("/"); - } - }, [isAuthenticated, router]); - - const hasWikiReadPermission = hasPermission("wiki:page:read"); - - return ( -
-
-
-

- Sign in to NextWiki -

- {!hasWikiReadPermission && ( -

- This is a private wiki. You need to be logged in to access it. -

- )} -
- - Loading login form...
}> - - -
- - {/* Show the back to home button if the user has the wiki:page:read permission, otherwise they will be redirected back here so no need to show it */} - {hasWikiReadPermission && ( - - )} - - ); -} diff --git a/apps/web/src/app/api/[404]/route.ts b/apps/web/src/app/api/[404]/route.ts index 4bf660a..d5caf65 100644 --- a/apps/web/src/app/api/[404]/route.ts +++ b/apps/web/src/app/api/[404]/route.ts @@ -1,5 +1,7 @@ import { NextResponse } from "next/server"; +export const dynamic = "force-static"; + export async function GET() { return NextResponse.json({ message: "Not Found" }, { status: 404 }); } diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 5a4caa5..fbda808 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -92,7 +92,7 @@ const poolSize = 10; switch (connectionType) { case ConnectionType.VERCEL_POSTGRES: - console.log("Using Vercel Postgres pool driver (POSTGRES_URL detected)"); + logger.log("Using Vercel Postgres pool driver (POSTGRES_URL detected)"); // Use createPool as recommended for Vercel's own Postgres // We know vercelPostgresUrl is defined here due to getConnectionType logic db = drizzleVercel( @@ -104,18 +104,19 @@ switch (connectionType) { break; case ConnectionType.NEON: - console.log( - "Using Neon database driver (DATABASE_URL contains .neon.tech)" - ); + logger.log("Using Neon database driver (DATABASE_URL contains .neon.tech)"); // We know databaseUrl is defined here due to getConnectionType logic neonConfig.fetchConnectionCache = true; db = drizzleNeon(neon(databaseUrl!), { schema }); break; case ConnectionType.VERCEL_EXTERNAL_POOL: - console.warn( + logger.warn( "Using standard pg.Pool with external DATABASE_URL on Vercel. Ensure the URL points to a pooler." ); + logger.warn( + "[CRITICAL] Ensure the pooler mode is set to 'transaction' or that you have a very beefy database server otherwise IT WILL use all your database connections." + ); // We know databaseUrl is defined here due to getConnectionType logic db = drizzlePg( new pg.Pool({ @@ -127,11 +128,11 @@ switch (connectionType) { break; case ConnectionType.STANDARD_POOL: - console.log( + logger.log( "Using standard PostgreSQL driver (pg.Pool) with DATABASE_URL (Not on Vercel/Neon)" ); // We know databaseUrl is defined here due to getConnectionType logic - console.log(`Using pg.Pool with pool size: ${poolSize}`); + logger.log(`Using pg.Pool with pool size: ${poolSize}`); db = drizzlePg( new pg.Pool({ connectionString: databaseUrl!,