Connect.constants.ts 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. import { type CodeBlockLang } from 'ui-patterns/CodeBlock'
  2. import { DOCS_URL } from '@/lib/constants'
  3. export type DatabaseConnectionType =
  4. | 'uri'
  5. | 'psql'
  6. | 'golang'
  7. | 'jdbc'
  8. | 'dotnet'
  9. | 'nodejs'
  10. | 'php'
  11. | 'python'
  12. | 'sqlalchemy'
  13. export const DATABASE_CONNECTION_TYPES: {
  14. id: DatabaseConnectionType
  15. label: string
  16. contentType: 'input' | 'code'
  17. lang: CodeBlockLang
  18. fileTitle: string | undefined
  19. }[] = [
  20. { id: 'uri', label: 'URI', contentType: 'input', lang: 'bash', fileTitle: undefined },
  21. { id: 'psql', label: 'PSQL', contentType: 'code', lang: 'bash', fileTitle: undefined },
  22. { id: 'golang', label: 'Golang', contentType: 'code', lang: 'go', fileTitle: '.env' },
  23. { id: 'jdbc', label: 'JDBC', contentType: 'input', lang: 'bash', fileTitle: undefined },
  24. {
  25. id: 'dotnet',
  26. label: '.NET',
  27. contentType: 'code',
  28. lang: 'csharp',
  29. fileTitle: 'appsettings.json',
  30. },
  31. { id: 'nodejs', label: 'Node.js', contentType: 'code', lang: 'js', fileTitle: '.env' },
  32. { id: 'php', label: 'PHP', contentType: 'code', lang: 'php', fileTitle: '.env' },
  33. { id: 'python', label: 'Python', contentType: 'code', lang: 'python', fileTitle: '.env' },
  34. { id: 'sqlalchemy', label: 'SQLAlchemy', contentType: 'code', lang: 'python', fileTitle: '.env' },
  35. ]
  36. export const CONNECTION_PARAMETERS = {
  37. host: {
  38. key: 'host',
  39. description: 'The hostname of your database',
  40. },
  41. port: {
  42. key: 'port',
  43. description: 'Port number for the connection',
  44. },
  45. database: {
  46. key: 'database',
  47. description: 'Default database name',
  48. },
  49. user: {
  50. key: 'user',
  51. description: 'Database user',
  52. },
  53. pool_mode: {
  54. key: 'pool_mode',
  55. description: 'Connection pooling behavior',
  56. },
  57. } as const
  58. export type ConnectionType = {
  59. key: string
  60. icon: string
  61. label: string
  62. guideLink?: string
  63. children: ConnectionType[]
  64. files?: {
  65. name: string
  66. content: string
  67. }[]
  68. }
  69. export const FRAMEWORKS: ConnectionType[] = [
  70. {
  71. key: 'nextjs',
  72. label: 'Next.js',
  73. icon: 'nextjs',
  74. guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/nextjs`,
  75. children: [
  76. {
  77. key: 'app',
  78. label: 'App Router',
  79. icon: '',
  80. children: [
  81. {
  82. key: 'brivenjs',
  83. label: 'briven-js',
  84. icon: 'briven',
  85. children: [],
  86. },
  87. ],
  88. },
  89. {
  90. key: 'pages',
  91. label: 'Pages Router',
  92. icon: '',
  93. children: [
  94. {
  95. key: 'brivenjs',
  96. label: 'Briven-js',
  97. children: [],
  98. icon: 'briven',
  99. },
  100. ],
  101. },
  102. ],
  103. },
  104. {
  105. key: 'remix',
  106. label: 'Remix',
  107. icon: 'remix',
  108. guideLink: `${DOCS_URL}/guides/auth/server-side/creating-a-client?framework=remix&environment=remix-loader`,
  109. children: [
  110. {
  111. key: 'brivenjs',
  112. label: 'Briven-js',
  113. children: [],
  114. icon: 'briven',
  115. },
  116. ],
  117. },
  118. {
  119. key: 'react',
  120. label: 'React',
  121. icon: 'react',
  122. guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/reactjs`,
  123. children: [
  124. {
  125. key: 'vite',
  126. label: 'Vite',
  127. icon: 'vite',
  128. children: [
  129. {
  130. key: 'brivenjs',
  131. label: 'Briven-js',
  132. children: [],
  133. icon: 'briven',
  134. },
  135. ],
  136. },
  137. {
  138. key: 'create-react-app',
  139. label: 'Create React App',
  140. icon: 'react',
  141. children: [
  142. {
  143. key: 'brivenjs',
  144. label: 'briven-js',
  145. icon: 'briven',
  146. children: [],
  147. },
  148. ],
  149. },
  150. ],
  151. },
  152. {
  153. key: 'nuxt',
  154. label: 'Nuxt',
  155. icon: 'nuxt',
  156. guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/nuxtjs`,
  157. children: [
  158. {
  159. key: 'brivenjs',
  160. label: 'Briven-js',
  161. children: [],
  162. icon: 'briven',
  163. },
  164. ],
  165. },
  166. {
  167. key: 'vuejs',
  168. label: 'Vue.JS',
  169. icon: 'vuejs',
  170. guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/vue`,
  171. children: [
  172. {
  173. key: 'brivenjs',
  174. label: 'Briven-js',
  175. children: [],
  176. icon: 'briven',
  177. },
  178. ],
  179. },
  180. {
  181. key: 'sveltekit',
  182. label: 'SvelteKit',
  183. icon: 'sveltekit',
  184. guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/sveltekit`,
  185. children: [
  186. {
  187. key: 'brivenjs',
  188. label: 'Briven-js',
  189. children: [],
  190. icon: 'briven',
  191. },
  192. ],
  193. },
  194. {
  195. key: 'solidjs',
  196. label: 'Solid.js',
  197. icon: 'solidjs',
  198. guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/solidjs`,
  199. children: [
  200. {
  201. key: 'brivenjs',
  202. label: 'Briven-js',
  203. children: [],
  204. icon: 'briven',
  205. },
  206. ],
  207. },
  208. {
  209. key: 'astro',
  210. label: 'Astro',
  211. icon: 'astro',
  212. guideLink: 'https://docs.astro.build/en/guides/backend/briven/',
  213. children: [
  214. {
  215. key: 'brivenjs',
  216. label: 'Briven-js',
  217. children: [],
  218. icon: 'briven',
  219. },
  220. ],
  221. },
  222. {
  223. key: 'refine',
  224. label: 'Refine',
  225. icon: 'refine',
  226. guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/refine`,
  227. children: [
  228. {
  229. key: 'brivenjs',
  230. label: 'Briven-js',
  231. children: [],
  232. icon: 'briven',
  233. },
  234. ],
  235. },
  236. {
  237. key: 'tanstack',
  238. label: 'TanStack Start',
  239. icon: 'tanstack',
  240. guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/tanstack`,
  241. children: [
  242. {
  243. key: 'brivenjs',
  244. label: 'Briven-js',
  245. children: [],
  246. icon: 'briven',
  247. },
  248. ],
  249. },
  250. {
  251. key: 'flask',
  252. label: 'Flask (Python)',
  253. icon: 'python',
  254. guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/flask`,
  255. children: [
  256. {
  257. key: 'brivenpy',
  258. label: 'briven-py',
  259. children: [],
  260. icon: 'briven',
  261. },
  262. ],
  263. },
  264. ]
  265. export const MOBILES: ConnectionType[] = [
  266. {
  267. key: 'exporeactnative',
  268. label: 'Expo React Native',
  269. icon: 'expo',
  270. guideLink: `${DOCS_URL}/guides/getting-started/quickstarts/expo-react-native`,
  271. children: [
  272. {
  273. key: 'brivenjs',
  274. label: 'Briven-js',
  275. children: [],
  276. icon: 'briven',
  277. },
  278. ],
  279. },
  280. {
  281. key: 'flutter',
  282. label: 'Flutter',
  283. icon: 'flutter',
  284. guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-flutter`,
  285. children: [
  286. {
  287. key: 'brivenflutter',
  288. label: 'briven-flutter',
  289. children: [],
  290. icon: 'briven',
  291. },
  292. ],
  293. },
  294. {
  295. key: 'ionicreact',
  296. label: 'Ionic React',
  297. icon: 'react',
  298. guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-ionic-react`,
  299. children: [
  300. {
  301. key: 'brivenjs',
  302. label: 'Briven-js',
  303. children: [],
  304. icon: 'briven',
  305. },
  306. ],
  307. },
  308. {
  309. key: 'swift',
  310. label: 'Swift',
  311. icon: 'swift',
  312. guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-swift`,
  313. children: [
  314. {
  315. key: 'brivenswift',
  316. label: 'briven-swift',
  317. children: [],
  318. icon: 'briven',
  319. },
  320. ],
  321. },
  322. {
  323. key: 'androidkotlin',
  324. label: 'Android Kotlin',
  325. icon: 'kotlin',
  326. guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-kotlin`,
  327. children: [
  328. {
  329. key: 'brivenkt',
  330. label: 'briven-kt',
  331. children: [],
  332. icon: 'briven',
  333. },
  334. ],
  335. },
  336. {
  337. key: 'ionicangular',
  338. label: 'Ionic Angular',
  339. icon: 'ionic-angular',
  340. guideLink: `${DOCS_URL}/guides/getting-started/tutorials/with-ionic-angular`,
  341. children: [
  342. {
  343. key: 'brivenjs',
  344. label: 'Briven-js',
  345. children: [],
  346. icon: 'briven',
  347. },
  348. ],
  349. },
  350. ]
  351. export const ORMS: ConnectionType[] = [
  352. {
  353. key: 'prisma',
  354. label: 'Prisma',
  355. icon: 'prisma',
  356. guideLink: 'https://supabase.com/partners/integrations/prisma',
  357. children: [],
  358. },
  359. {
  360. key: 'drizzle',
  361. label: 'Drizzle',
  362. icon: 'drizzle',
  363. guideLink: `${DOCS_URL}/guides/database/connecting-to-postgres#connecting-with-drizzle`,
  364. children: [],
  365. },
  366. ]
  367. export const CONNECTION_TYPES = [
  368. { key: 'direct', label: 'Connection String', obj: [] },
  369. { key: 'frameworks', label: 'App Frameworks', obj: FRAMEWORKS },
  370. { key: 'mobiles', label: 'Mobile Frameworks', obj: MOBILES },
  371. { key: 'orms', label: 'ORMs', obj: ORMS },
  372. { key: 'mcp', label: 'MCP', obj: [] },
  373. ]
  374. export const PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT =
  375. 'Purchase IPv4 add-on or use Shared Pooler if on a IPv4 network'
  376. export const IPV4_ADDON_TEXT = 'Connections are IPv4 proxied with IPv4 add-on'
  377. export type ConnectionStringMethod = 'direct' | 'transaction' | 'session'
  378. export const connectionStringMethodOptions: Record<
  379. ConnectionStringMethod,
  380. { value: string; label: string; description: string }
  381. > = {
  382. direct: {
  383. value: 'direct',
  384. label: 'Direct connection',
  385. description:
  386. 'Ideal for applications with persistent and long-lived connections, such as those running on virtual machines or long-standing containers.',
  387. },
  388. transaction: {
  389. value: 'transaction',
  390. label: 'Transaction pooler',
  391. description:
  392. 'Ideal for stateless applications like serverless functions where each interaction with Postgres is brief and isolated.',
  393. },
  394. session: {
  395. value: 'session',
  396. label: 'Session pooler',
  397. description:
  398. 'Only recommended as an alternative to Direct Connection, when connecting via an IPv4 network.',
  399. },
  400. }