INNER CODE UNIT · TypeScript

createDatabase

miurla/morphic · lib/db/index.ts:26

const createDatabase = (url: string) => {
  // Log which connection is being used (for debugging)
  if (isDevelopment) {
    console.log(
      '[DB] Using connection:',
      restrictedDatabaseUrl
        ? 'Restricted User (RLS Active)'
        : 'Owner User (RLS Bypassed)'
    )
  }

  // SSL configuration: Use environment variable to control SSL
  // DATABASE_SSL_DISABLED=true disables SSL completely (for local/Docker PostgreSQL)
  // Default is to enable SSL with certificate verification (for cloud databases like Neon, Supabase)
  const sslConfig =
    process.env.DATABASE_SSL_DISABLED === 'true'
      ? false // Disable SSL entirely for local PostgreSQL
      : { rejectUnauthorized: true } // Enable SSL with verification for cloud DBs

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…