summaryrefslogtreecommitdiff
path: root/apps/mobile/lib/config.ts
blob: 70fce52beacbe2df1dfe687d1bcdd8877ec46a13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { Platform } from 'react-native';

/**
 * API configuration for Makima mobile app
 * Supports different environments and platforms
 */

// Environment detection
const isDevelopment = __DEV__;

/**
 * API base URLs for different environments
 */
export const API_CONFIG = {
  local: 'http://localhost:8080',
  // Use 10.0.2.2 for Android emulator to access host machine's localhost
  localAndroid: 'http://10.0.2.2:8080',
  production: 'https://api.makima.jp',
} as const;

/**
 * Get the appropriate API base URL based on environment and platform
 */
export function getApiBaseUrl(): string {
  // Check for environment variable override
  const envUrl = process.env.EXPO_PUBLIC_API_URL;
  if (envUrl) {
    return envUrl;
  }

  // In production, use the production API
  if (!isDevelopment) {
    return API_CONFIG.production;
  }

  // In development, use local API with platform-specific URL
  if (Platform.OS === 'android') {
    return API_CONFIG.localAndroid;
  }

  return API_CONFIG.local;
}

/**
 * App configuration object
 */
export const config = {
  /**
   * API base URL for making requests
   */
  apiBaseUrl: getApiBaseUrl(),

  /**
   * Whether the app is running in development mode
   */
  isDevelopment,

  /**
   * Supabase URL (from environment or default)
   */
  supabaseUrl: process.env.EXPO_PUBLIC_SUPABASE_URL || 'https://ynxyjytytmfwxjqxljzm.supabase.co',

  /**
   * App version
   */
  version: '1.0.0',

  /**
   * Support/help URL
   */
  supportUrl: 'https://makima.jp/support',

  /**
   * Privacy policy URL
   */
  privacyPolicyUrl: 'https://makima.jp/privacy',

  /**
   * Terms of service URL
   */
  termsOfServiceUrl: 'https://makima.jp/terms',

  /**
   * Forgot password URL (opens in browser)
   */
  forgotPasswordUrl: 'https://makima.jp/forgot-password',
} as const;

export type Config = typeof config;