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