index.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Ignore barrel file rule here since it's just exporting more constants
  2. // eslint-disable-next-line barrel-files/avoid-re-export-all
  3. export * from './infrastructure'
  4. export const IS_PLATFORM = process.env.NEXT_PUBLIC_IS_PLATFORM === 'true'
  5. /**
  6. * Indicates that the app is running in a test environment (E2E tests).
  7. * Set via NEXT_PUBLIC_NODE_ENV=test in the generateLocalEnv.js script.
  8. */
  9. export const IS_TEST_ENV = process.env.NEXT_PUBLIC_NODE_ENV === 'test'
  10. /**
  11. * True when running against the staging or local environments. Used to gate
  12. * staff-only debugging affordances (e.g. the unified logs OTEL toggle) that
  13. * should never be visible to customers on production.
  14. */
  15. export const IS_STAGING_OR_LOCAL =
  16. process.env.NEXT_PUBLIC_ENVIRONMENT === 'staging' ||
  17. process.env.NEXT_PUBLIC_ENVIRONMENT === 'local'
  18. export const API_URL = (() => {
  19. // briven: prefer explicit BRIVEN_API_URL over platform detection
  20. if (process.env.NEXT_PUBLIC_BRIVEN_API_URL) return process.env.NEXT_PUBLIC_BRIVEN_API_URL
  21. if (process.env.NODE_ENV === 'test') return 'http://localhost:3000/api'
  22. // If running in platform, use API_URL from the env var
  23. if (IS_PLATFORM) return process.env.NEXT_PUBLIC_API_URL!
  24. // If running in browser, let it add the host
  25. if (typeof window !== 'undefined') return '/api'
  26. // If running self-hosted Vercel preview, use VERCEL_URL
  27. if (!!process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}/api`
  28. // If running on self-hosted, use NEXT_PUBLIC_SITE_URL
  29. if (!!process.env.NEXT_PUBLIC_SITE_URL) return `${process.env.NEXT_PUBLIC_SITE_URL}/api`
  30. // briven default: control plane on localhost:3001
  31. return 'http://localhost:3001'
  32. })()
  33. export const PG_META_URL = process.env.NEXT_PUBLIC_BRIVEN_API_URL
  34. ? `${process.env.NEXT_PUBLIC_BRIVEN_API_URL}/platform/pg-meta`
  35. : process.env.STUDIO_PG_META_URL || "http://localhost:3001/platform/pg-meta"
  36. export const BASE_PATH = process.env.NEXT_PUBLIC_BASE_PATH ?? ''
  37. /**
  38. * @deprecated use DATETIME_FORMAT
  39. */
  40. export const DATE_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ'
  41. // should be used for all dayjs formattings shown to the user. Includes timezone info.
  42. export const DATETIME_FORMAT = 'DD MMM YYYY, HH:mm:ss (ZZ)'
  43. export const GOTRUE_ERRORS = {
  44. UNVERIFIED_GITHUB_USER: 'Error sending confirmation mail',
  45. }
  46. export const STRIPE_PUBLIC_KEY =
  47. process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY || 'pk_test_XVwg5IZH3I9Gti98hZw6KRzd00v5858heG'
  48. export const POSTHOG_URL =
  49. process.env.NEXT_PUBLIC_ENVIRONMENT === 'staging' ||
  50. process.env.NEXT_PUBLIC_ENVIRONMENT === 'local'
  51. ? 'https://ph.briven.green'
  52. : 'https://ph.briven.tech'
  53. export const USAGE_APPROACHING_THRESHOLD = 0.75
  54. export const DOCS_URL = process.env.NEXT_PUBLIC_DOCS_URL || 'https://docs.briven.tech'
  55. export const OPT_IN_TAGS = {
  56. AI_SQL: 'AI_SQL_GENERATOR_OPT_IN',
  57. AI_DATA: 'AI_DATA_GENERATOR_OPT_IN',
  58. AI_LOG: 'AI_LOG_GENERATOR_OPT_IN',
  59. }
  60. export const GB = 1024 * 1024 * 1024
  61. export const MB = 1024 * 1024
  62. export const KB = 1024
  63. export const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i