content.tsx73 lines · main
| 1 | import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock' |
| 2 | |
| 3 | import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types' |
| 4 | import { |
| 5 | ConnectTabContent, |
| 6 | ConnectTabs, |
| 7 | ConnectTabTrigger, |
| 8 | ConnectTabTriggers, |
| 9 | } from '@/components/interfaces/Connect/ConnectTabs' |
| 10 | import { IS_PLATFORM } from '@/lib/constants' |
| 11 | |
| 12 | const ContentFile = ({ connectionStringPooler }: ContentFileProps) => { |
| 13 | return ( |
| 14 | <ConnectTabs> |
| 15 | <ConnectTabTriggers> |
| 16 | <ConnectTabTrigger value=".env.local" /> |
| 17 | <ConnectTabTrigger value="prisma/schema.prisma" /> |
| 18 | </ConnectTabTriggers> |
| 19 | |
| 20 | <ConnectTabContent value=".env.local"> |
| 21 | <SimpleCodeBlock className="bash" parentClassName="min-h-72"> |
| 22 | {connectionStringPooler.ipv4SupportedForDedicatedPooler && |
| 23 | connectionStringPooler.transactionDedicated |
| 24 | ? ` |
| 25 | # Connect to Briven via connection pooling. |
| 26 | DATABASE_URL="${connectionStringPooler.transactionDedicated}?pgbouncer=true" |
| 27 | |
| 28 | # Direct connection to the database. Used for migrations. |
| 29 | DIRECT_URL="${connectionStringPooler.sessionDedicated}" |
| 30 | ` |
| 31 | : connectionStringPooler.transactionDedicated && |
| 32 | !connectionStringPooler.ipv4SupportedForDedicatedPooler |
| 33 | ? ` |
| 34 | # Connect to Briven via Shared Connection Pooler |
| 35 | DATABASE_URL="${connectionStringPooler.transactionShared}?pgbouncer=true" |
| 36 | |
| 37 | # Direct connection to the database through Shared Pooler (supports IPv4/IPv6). Used for migrations. |
| 38 | DIRECT_URL="${connectionStringPooler.sessionShared}" |
| 39 | |
| 40 | # If your network supports IPv6 or you purchased IPv4 addon, use dedicated pooler |
| 41 | # DATABASE_URL="${connectionStringPooler.transactionDedicated}?pgbouncer=true" |
| 42 | # DIRECT_URL="${connectionStringPooler.sessionDedicated}" |
| 43 | ` |
| 44 | : ` |
| 45 | # Connect to Briven ${IS_PLATFORM ? 'via connection pooling' : ''} |
| 46 | DATABASE_URL="${IS_PLATFORM ? `${connectionStringPooler.transactionShared}?pgbouncer=true` : connectionStringPooler.direct}" |
| 47 | |
| 48 | # Direct connection to the database. Used for migrations |
| 49 | DIRECT_URL="${IS_PLATFORM ? connectionStringPooler.sessionShared : connectionStringPooler.direct}" |
| 50 | `} |
| 51 | </SimpleCodeBlock> |
| 52 | </ConnectTabContent> |
| 53 | |
| 54 | <ConnectTabContent value="prisma/schema.prisma"> |
| 55 | <SimpleCodeBlock className="bash" parentClassName="min-h-72"> |
| 56 | {` |
| 57 | generator client { |
| 58 | provider = "prisma-client-js" |
| 59 | } |
| 60 | |
| 61 | datasource db { |
| 62 | provider = "postgresql" |
| 63 | url = env("DATABASE_URL") |
| 64 | directUrl = env("DIRECT_URL") |
| 65 | } |
| 66 | `} |
| 67 | </SimpleCodeBlock> |
| 68 | </ConnectTabContent> |
| 69 | </ConnectTabs> |
| 70 | ) |
| 71 | } |
| 72 | |
| 73 | export default ContentFile |