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