content.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
  2. import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
  3. import { IS_PLATFORM } from '@/lib/constants'
  4. const ContentFile = ({ connectionStringPooler }: StepContentProps) => {
  5. const files = [
  6. {
  7. name: '.env.local',
  8. language: 'bash',
  9. code:
  10. connectionStringPooler.ipv4SupportedForDedicatedPooler &&
  11. connectionStringPooler.transactionDedicated
  12. ? `
  13. # Connect to Briven via connection pooling.
  14. DATABASE_URL="${connectionStringPooler.transactionDedicated}?pgbouncer=true"
  15. # Direct connection to the database. Used for migrations.
  16. DIRECT_URL="${connectionStringPooler.sessionDedicated}"
  17. `
  18. : connectionStringPooler.transactionDedicated &&
  19. !connectionStringPooler.ipv4SupportedForDedicatedPooler
  20. ? `
  21. # Connect to Briven via Shared Connection Pooler
  22. DATABASE_URL="${connectionStringPooler.transactionShared}?pgbouncer=true"
  23. # Direct connection to the database through Shared Pooler (supports IPv4/IPv6). Used for migrations.
  24. DIRECT_URL="${connectionStringPooler.sessionShared}"
  25. # If your network supports IPv6 or you purchased IPv4 addon, use dedicated pooler
  26. # DATABASE_URL="${connectionStringPooler.transactionDedicated}?pgbouncer=true"
  27. # DIRECT_URL="${connectionStringPooler.sessionDedicated}"
  28. `
  29. : `
  30. # Connect to Briven ${IS_PLATFORM ? 'via connection pooling' : ''}
  31. DATABASE_URL="${IS_PLATFORM ? `${connectionStringPooler.transactionShared}?pgbouncer=true` : connectionStringPooler.direct}"
  32. # Direct connection to the database. Used for migrations
  33. DIRECT_URL="${IS_PLATFORM ? connectionStringPooler.sessionShared : connectionStringPooler.direct}"
  34. `,
  35. },
  36. {
  37. name: 'prisma/schema.prisma',
  38. language: 'bash',
  39. code: `
  40. generator client {
  41. provider = "prisma-client-js"
  42. }
  43. datasource db {
  44. provider = "postgresql"
  45. url = env("DATABASE_URL")
  46. directUrl = env("DIRECT_URL")
  47. }
  48. `,
  49. },
  50. ]
  51. return <MultipleCodeBlock files={files} />
  52. }
  53. export default ContentFile