- apiBaseUrl: https://api.lions.dev → https://api.lions.dev/unionflow (l'ingress K8s route /unionflow/* vers le backend) - wsBaseUrl: wss://api.lions.dev → wss://api.lions.dev/unionflow - Bundler 13 fichiers TTF Roboto dans google_fonts/ (GoogleFonts.allowRuntimeFetching=false en prod crashait sans fonts locales) - Déclarer google_fonts/ dans pubspec.yaml assets
101 lines
3.4 KiB
Dart
101 lines
3.4 KiB
Dart
import 'local_config.dart';
|
|
|
|
/// Environnements de déploiement de l'application
|
|
enum Environment { dev, staging, prod }
|
|
|
|
/// Configuration centralisée par environnement.
|
|
/// Les URLs sont injectées via --dart-define=ENV=dev|staging|prod
|
|
/// L'IP dev est définie dans android/local.properties → dev.host
|
|
/// (propagée automatiquement vers ce fichier via build.gradle).
|
|
class AppConfig {
|
|
static late final Environment _environment;
|
|
static late final String apiBaseUrl;
|
|
static late final String keycloakBaseUrl;
|
|
static late final String wsBaseUrl;
|
|
static late final bool enableDebugMode;
|
|
static late final bool enableLogging;
|
|
static late final bool enableCrashReporting;
|
|
static late final bool enableAnalytics;
|
|
|
|
/// Initialise la configuration à partir de l'environnement.
|
|
/// Appeler dans main() avant runApp().
|
|
static void initialize() {
|
|
const envString = String.fromEnvironment('ENV', defaultValue: 'dev');
|
|
_environment = Environment.values.firstWhere(
|
|
(e) => e.name == envString,
|
|
orElse: () => Environment.dev,
|
|
);
|
|
|
|
switch (_environment) {
|
|
case Environment.dev:
|
|
apiBaseUrl = const String.fromEnvironment(
|
|
'API_URL',
|
|
defaultValue: 'http://$kDevHost:8085',
|
|
);
|
|
keycloakBaseUrl = const String.fromEnvironment(
|
|
'KEYCLOAK_URL',
|
|
defaultValue: 'http://$kDevHost:8180',
|
|
);
|
|
wsBaseUrl = const String.fromEnvironment(
|
|
'WS_URL',
|
|
defaultValue: 'ws://$kDevHost:8085',
|
|
);
|
|
enableDebugMode = true;
|
|
enableLogging = true;
|
|
enableCrashReporting = false;
|
|
enableAnalytics = false;
|
|
|
|
case Environment.staging:
|
|
apiBaseUrl = const String.fromEnvironment(
|
|
'API_URL',
|
|
defaultValue: 'https://api-staging.lions.dev',
|
|
);
|
|
keycloakBaseUrl = const String.fromEnvironment(
|
|
'KEYCLOAK_URL',
|
|
defaultValue: 'https://security-staging.lions.dev',
|
|
);
|
|
wsBaseUrl = const String.fromEnvironment(
|
|
'WS_URL',
|
|
defaultValue: 'wss://api-staging.lions.dev',
|
|
);
|
|
enableDebugMode = false;
|
|
enableLogging = true;
|
|
enableCrashReporting = true;
|
|
enableAnalytics = false;
|
|
|
|
case Environment.prod:
|
|
apiBaseUrl = const String.fromEnvironment(
|
|
'API_URL',
|
|
defaultValue: 'https://api.lions.dev/unionflow',
|
|
);
|
|
keycloakBaseUrl = const String.fromEnvironment(
|
|
'KEYCLOAK_URL',
|
|
defaultValue: 'https://security.lions.dev',
|
|
);
|
|
wsBaseUrl = const String.fromEnvironment(
|
|
'WS_URL',
|
|
defaultValue: 'wss://api.lions.dev/unionflow',
|
|
);
|
|
enableDebugMode = false;
|
|
enableLogging = false;
|
|
enableCrashReporting = true;
|
|
enableAnalytics = true;
|
|
}
|
|
}
|
|
|
|
static Environment get environment => _environment;
|
|
static bool get isDev => _environment == Environment.dev;
|
|
static bool get isStaging => _environment == Environment.staging;
|
|
static bool get isProd => _environment == Environment.prod;
|
|
|
|
/// URL complète du realm Keycloak
|
|
static String get keycloakRealmUrl => '$keycloakBaseUrl/realms/unionflow';
|
|
|
|
/// URL du endpoint token Keycloak
|
|
static String get keycloakTokenUrl =>
|
|
'$keycloakRealmUrl/protocol/openid-connect/token';
|
|
|
|
/// URL du endpoint WebSocket dashboard
|
|
static String get wsDashboardUrl => '$wsBaseUrl/ws/dashboard';
|
|
}
|