infrastructure.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import { AWS_REGIONS, FLY_REGIONS } from 'shared-data'
  2. import type { components } from '@/data/api'
  3. import { useCustomContent } from '@/hooks/custom-content/useCustomContent'
  4. export const AWS_REGIONS_DEFAULT =
  5. process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod'
  6. ? AWS_REGIONS.SOUTHEAST_ASIA
  7. : AWS_REGIONS.EAST_US_2
  8. // TO DO, change default to US region for prod
  9. export const FLY_REGIONS_DEFAULT = FLY_REGIONS.SOUTHEAST_ASIA
  10. export const MANAGED_BY = {
  11. VERCEL_MARKETPLACE: 'vercel-marketplace',
  12. AWS_MARKETPLACE: 'aws-marketplace',
  13. STRIPE_PROJECTS: 'stripe-projects',
  14. BRIVEN: 'briven',
  15. }
  16. export type ManagedBy = (typeof MANAGED_BY)[keyof typeof MANAGED_BY]
  17. export const PRICING_TIER_LABELS_ORG = {
  18. FREE: 'Free - $0/month',
  19. PRO: 'Pro - $25/month',
  20. TEAM: 'Team - $599/month',
  21. }
  22. export const PRICING_TIER_PRODUCT_IDS = {
  23. FREE: 'tier_free',
  24. PRO: 'tier_pro',
  25. PAYG: 'tier_payg',
  26. TEAM: 'tier_team',
  27. ENTERPRISE: 'tier_enterprise',
  28. }
  29. export function useDefaultProvider() {
  30. const defaultProvider = 'AWS'
  31. const { infraCloudProviders: validCloudProviders } = useCustomContent(['infra:cloud_providers'])
  32. if (validCloudProviders?.includes(defaultProvider)) {
  33. return defaultProvider
  34. }
  35. return validCloudProviders?.[0] ?? 'AWS'
  36. }
  37. export const PROVIDERS = {
  38. FLY: {
  39. id: 'FLY',
  40. name: 'Fly.io',
  41. default_region: FLY_REGIONS_DEFAULT,
  42. regions: { ...FLY_REGIONS },
  43. },
  44. AWS: {
  45. id: 'AWS',
  46. name: 'AWS',
  47. DEFAULT_SSH_KEY: 'briven-app-instance',
  48. default_region: AWS_REGIONS_DEFAULT,
  49. regions: { ...AWS_REGIONS },
  50. },
  51. AWS_K8S: {
  52. id: 'AWS_K8S',
  53. name: 'AWS (Revamped)',
  54. DEFAULT_SSH_KEY: 'briven-app-instance',
  55. default_region: AWS_REGIONS_DEFAULT,
  56. regions: { ...AWS_REGIONS },
  57. },
  58. AWS_NIMBUS: {
  59. id: 'AWS_NIMBUS',
  60. name: 'AWS (Nimbus)',
  61. default_region: AWS_REGIONS_DEFAULT,
  62. regions: { ...AWS_REGIONS },
  63. },
  64. } as const
  65. export const PROJECT_STATUS: {
  66. [key: string]: components['schemas']['ProjectDetailResponse']['status']
  67. } = {
  68. INACTIVE: 'INACTIVE',
  69. ACTIVE_HEALTHY: 'ACTIVE_HEALTHY',
  70. ACTIVE_UNHEALTHY: 'ACTIVE_UNHEALTHY',
  71. COMING_UP: 'COMING_UP',
  72. UNKNOWN: 'UNKNOWN',
  73. GOING_DOWN: 'GOING_DOWN',
  74. INIT_FAILED: 'INIT_FAILED',
  75. REMOVED: 'REMOVED',
  76. RESTARTING: 'RESTARTING',
  77. RESTORING: 'RESTORING',
  78. RESTORE_FAILED: 'RESTORE_FAILED',
  79. UPGRADING: 'UPGRADING',
  80. PAUSING: 'PAUSING',
  81. PAUSE_FAILED: 'PAUSE_FAILED',
  82. RESIZING: 'RESIZING',
  83. }
  84. export const DEFAULT_MINIMUM_PASSWORD_STRENGTH = 4
  85. export const PASSWORD_STRENGTH = {
  86. 0: 'This password is not acceptable.',
  87. 1: 'This password is not secure enough.',
  88. 2: 'This password is not secure enough.',
  89. 3: 'Not bad, but your password must be harder to guess.',
  90. 4: 'This password is strong.',
  91. }
  92. export const PASSWORD_STRENGTH_COLOR = {
  93. 0: 'bg-red-900',
  94. 1: 'bg-red-900',
  95. 2: 'bg-yellow-900',
  96. 3: 'bg-yellow-900',
  97. 4: 'bg-green-900',
  98. }
  99. export const PASSWORD_STRENGTH_PERCENTAGE = {
  100. 0: 10,
  101. 1: 30,
  102. 2: 50,
  103. 3: 80,
  104. 4: 100,
  105. }
  106. export const DEFAULT_PROJECT_API_SERVICE_ID = 1
  107. export type InstanceSpecs = {
  108. baseline_disk_io_mbs: number
  109. connections_direct: number
  110. connections_pooler: number
  111. cpu_cores: number | 'Shared'
  112. cpu_dedicated: boolean
  113. max_disk_io_mbs: number
  114. memory_gb: number
  115. }
  116. export const INSTANCE_NANO_SPECS: InstanceSpecs = {
  117. baseline_disk_io_mbs: 43,
  118. connections_direct: 30,
  119. connections_pooler: 200,
  120. cpu_cores: 'Shared',
  121. cpu_dedicated: false,
  122. max_disk_io_mbs: 2085,
  123. memory_gb: 0.5,
  124. }
  125. export const INSTANCE_MICRO_SPECS: InstanceSpecs = {
  126. baseline_disk_io_mbs: 87,
  127. connections_direct: 60,
  128. connections_pooler: 200,
  129. cpu_cores: 2,
  130. cpu_dedicated: false,
  131. max_disk_io_mbs: 2085,
  132. memory_gb: 1,
  133. }