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