settings.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { components } from 'api-types'
  2. import { assertSelfHosted } from './util'
  3. import { PROJECT_ENDPOINT, PROJECT_ENDPOINT_PROTOCOL } from '@/lib/constants/api'
  4. type ProjectAppConfig = components['schemas']['ProjectSettingsResponse']['app_config'] & {
  5. protocol?: string
  6. }
  7. export type ProjectSettings = components['schemas']['ProjectSettingsResponse'] & {
  8. app_config?: ProjectAppConfig
  9. }
  10. /**
  11. * Gets self-hosted project settings
  12. *
  13. * _Only call this from server-side self-hosted code._
  14. */
  15. export function getProjectSettings() {
  16. assertSelfHosted()
  17. const response = {
  18. app_config: {
  19. db_schema: 'public',
  20. endpoint: PROJECT_ENDPOINT,
  21. storage_endpoint: PROJECT_ENDPOINT,
  22. // manually added to force the frontend to use the correct URL
  23. protocol: PROJECT_ENDPOINT_PROTOCOL,
  24. },
  25. cloud_provider: 'AWS',
  26. db_dns_name: '-',
  27. db_host: 'localhost',
  28. db_ip_addr_config: 'legacy' as const,
  29. db_name: 'postgres',
  30. db_port: 5432,
  31. db_user: 'postgres',
  32. inserted_at: '2021-08-02T06:40:40.646Z',
  33. jwt_secret:
  34. process.env.AUTH_JWT_SECRET ?? 'super-secret-jwt-token-with-at-least-32-characters-long',
  35. name: process.env.DEFAULT_PROJECT_NAME || 'Default Project',
  36. ref: 'default',
  37. region: 'ap-southeast-1',
  38. service_api_keys: [
  39. {
  40. api_key: process.env.BRIVEN_SERVICE_KEY ?? '',
  41. name: 'service_role key',
  42. tags: 'service_role',
  43. },
  44. {
  45. api_key: process.env.BRIVEN_ANON_KEY ?? '',
  46. name: 'anon key',
  47. tags: 'anon',
  48. },
  49. ],
  50. ssl_enforced: false,
  51. status: 'ACTIVE_HEALTHY',
  52. } satisfies ProjectSettings
  53. return response
  54. }