pi-kiosk-shared 1.0.5 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,9 +4,28 @@ export interface EnvironmentConfig {
|
|
|
4
4
|
wsUrl: string;
|
|
5
5
|
enableMockPayments: boolean;
|
|
6
6
|
paymentAccountNumber: string;
|
|
7
|
+
paymentMode: 'mock' | 'sandbox' | 'production';
|
|
7
8
|
showDebugInfo: boolean;
|
|
9
|
+
logLevel: 'debug' | 'info' | 'warn' | 'error';
|
|
10
|
+
kioskUrl: string;
|
|
11
|
+
adminUrl: string;
|
|
12
|
+
backendUrl: string;
|
|
8
13
|
}
|
|
9
14
|
export declare const getCurrentEnvironment: () => Environment;
|
|
10
15
|
export declare const getEnvironmentConfig: () => EnvironmentConfig;
|
|
11
16
|
export declare const isDevelopment: () => boolean;
|
|
12
17
|
export declare const isProduction: () => boolean;
|
|
18
|
+
export declare const getBackendUrl: () => string;
|
|
19
|
+
export declare const getKioskUrl: () => string;
|
|
20
|
+
export declare const getAdminUrl: () => string;
|
|
21
|
+
export declare const getApiUrl: () => string;
|
|
22
|
+
export declare const getWsUrl: () => string;
|
|
23
|
+
export declare const getPaymentConfig: () => {
|
|
24
|
+
enableMockPayments: boolean;
|
|
25
|
+
paymentAccountNumber: string;
|
|
26
|
+
paymentMode: "production" | "mock" | "sandbox";
|
|
27
|
+
};
|
|
28
|
+
export declare const getUIConfig: () => {
|
|
29
|
+
showDebugInfo: boolean;
|
|
30
|
+
logLevel: "debug" | "info" | "warn" | "error";
|
|
31
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
2
|
+
// Centralized environment configuration for all services
|
|
3
|
+
// This ensures consistency across backend, kiosk, and admin apps
|
|
3
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.isProduction = exports.isDevelopment = exports.getEnvironmentConfig = exports.getCurrentEnvironment = void 0;
|
|
5
|
+
exports.getUIConfig = exports.getPaymentConfig = exports.getWsUrl = exports.getApiUrl = exports.getAdminUrl = exports.getKioskUrl = exports.getBackendUrl = exports.isProduction = exports.isDevelopment = exports.getEnvironmentConfig = exports.getCurrentEnvironment = void 0;
|
|
5
6
|
// Helper function to get environment variables dynamically
|
|
6
7
|
function getEnvVar(key, defaultValue) {
|
|
7
8
|
// Try to get from process.env (Node.js) or import.meta.env (Vite)
|
|
@@ -30,24 +31,56 @@ function getEnvBool(key, defaultValue) {
|
|
|
30
31
|
const value = getEnvVar(key, defaultValue.toString());
|
|
31
32
|
return value === 'true';
|
|
32
33
|
}
|
|
34
|
+
// Centralized service URLs configuration
|
|
35
|
+
const SERVICE_URLS = {
|
|
36
|
+
development: {
|
|
37
|
+
backend: 'http://localhost:3015',
|
|
38
|
+
kiosk: 'http://localhost:3000',
|
|
39
|
+
admin: 'http://localhost:3001',
|
|
40
|
+
},
|
|
41
|
+
production: {
|
|
42
|
+
backend: 'https://rpapp-bckend-production.up.railway.app',
|
|
43
|
+
kiosk: 'https://rpapp-kiosk-production.up.railway.app',
|
|
44
|
+
admin: 'https://extraordinary-healing-production-88f4.up.railway.app',
|
|
45
|
+
}
|
|
46
|
+
};
|
|
33
47
|
// Get environment configuration dynamically
|
|
34
48
|
function getConfigForEnvironment(env) {
|
|
49
|
+
const urls = SERVICE_URLS[env];
|
|
35
50
|
if (env === 'development') {
|
|
36
51
|
return {
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
// API Configuration
|
|
53
|
+
apiUrl: getEnvVar('REACT_APP_API_URL', urls.backend),
|
|
54
|
+
wsUrl: getEnvVar('REACT_APP_WS_URL', urls.backend.replace('http', 'ws')),
|
|
55
|
+
// Payment Configuration
|
|
39
56
|
enableMockPayments: getEnvBool('REACT_APP_ENABLE_MOCK_PAYMENTS', true),
|
|
40
57
|
paymentAccountNumber: getEnvVar('REACT_APP_PAYMENT_ACCOUNT', '1234567890'),
|
|
58
|
+
paymentMode: getEnvVar('REACT_APP_PAYMENT_MODE', 'mock'),
|
|
59
|
+
// UI Configuration
|
|
41
60
|
showDebugInfo: getEnvBool('REACT_APP_SHOW_DEBUG_INFO', true),
|
|
61
|
+
logLevel: getEnvVar('REACT_APP_LOG_LEVEL', 'debug'),
|
|
62
|
+
// Service URLs
|
|
63
|
+
kioskUrl: getEnvVar('REACT_APP_KIOSK_URL', urls.kiosk),
|
|
64
|
+
adminUrl: getEnvVar('REACT_APP_ADMIN_URL', urls.admin),
|
|
65
|
+
backendUrl: getEnvVar('REACT_APP_BACKEND_URL', urls.backend),
|
|
42
66
|
};
|
|
43
67
|
}
|
|
44
68
|
else {
|
|
45
69
|
return {
|
|
46
|
-
|
|
47
|
-
|
|
70
|
+
// API Configuration
|
|
71
|
+
apiUrl: getEnvVar('REACT_APP_API_URL', urls.backend),
|
|
72
|
+
wsUrl: getEnvVar('REACT_APP_WS_URL', urls.backend.replace('https', 'wss')),
|
|
73
|
+
// Payment Configuration
|
|
48
74
|
enableMockPayments: getEnvBool('REACT_APP_ENABLE_MOCK_PAYMENTS', false),
|
|
49
75
|
paymentAccountNumber: getEnvVar('REACT_APP_PAYMENT_ACCOUNT', '1234567890'),
|
|
76
|
+
paymentMode: getEnvVar('REACT_APP_PAYMENT_MODE', 'production'),
|
|
77
|
+
// UI Configuration
|
|
50
78
|
showDebugInfo: getEnvBool('REACT_APP_SHOW_DEBUG_INFO', false),
|
|
79
|
+
logLevel: getEnvVar('REACT_APP_LOG_LEVEL', 'warn'),
|
|
80
|
+
// Service URLs
|
|
81
|
+
kioskUrl: getEnvVar('REACT_APP_KIOSK_URL', urls.kiosk),
|
|
82
|
+
adminUrl: getEnvVar('REACT_APP_ADMIN_URL', urls.admin),
|
|
83
|
+
backendUrl: getEnvVar('REACT_APP_BACKEND_URL', urls.backend),
|
|
51
84
|
};
|
|
52
85
|
}
|
|
53
86
|
}
|
|
@@ -72,6 +105,13 @@ const getCurrentEnvironment = () => {
|
|
|
72
105
|
// Ignore errors, fall back to default
|
|
73
106
|
}
|
|
74
107
|
}
|
|
108
|
+
// Additional check: if we're on a Railway domain, assume production
|
|
109
|
+
if (!nodeEnv && typeof window !== 'undefined' && window.location) {
|
|
110
|
+
if (window.location.hostname.includes('railway.app') ||
|
|
111
|
+
window.location.hostname.includes('up.railway.app')) {
|
|
112
|
+
return 'production';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
75
115
|
return nodeEnv === 'production' ? 'production' : 'development';
|
|
76
116
|
};
|
|
77
117
|
exports.getCurrentEnvironment = getCurrentEnvironment;
|
|
@@ -86,3 +126,32 @@ const isDevelopment = () => (0, exports.getCurrentEnvironment)() === 'developmen
|
|
|
86
126
|
exports.isDevelopment = isDevelopment;
|
|
87
127
|
const isProduction = () => (0, exports.getCurrentEnvironment)() === 'production';
|
|
88
128
|
exports.isProduction = isProduction;
|
|
129
|
+
// Utility functions for easy access to service URLs
|
|
130
|
+
const getBackendUrl = () => (0, exports.getEnvironmentConfig)().backendUrl;
|
|
131
|
+
exports.getBackendUrl = getBackendUrl;
|
|
132
|
+
const getKioskUrl = () => (0, exports.getEnvironmentConfig)().kioskUrl;
|
|
133
|
+
exports.getKioskUrl = getKioskUrl;
|
|
134
|
+
const getAdminUrl = () => (0, exports.getEnvironmentConfig)().adminUrl;
|
|
135
|
+
exports.getAdminUrl = getAdminUrl;
|
|
136
|
+
const getApiUrl = () => (0, exports.getEnvironmentConfig)().apiUrl;
|
|
137
|
+
exports.getApiUrl = getApiUrl;
|
|
138
|
+
const getWsUrl = () => (0, exports.getEnvironmentConfig)().wsUrl;
|
|
139
|
+
exports.getWsUrl = getWsUrl;
|
|
140
|
+
// Service-specific configuration helpers
|
|
141
|
+
const getPaymentConfig = () => {
|
|
142
|
+
const config = (0, exports.getEnvironmentConfig)();
|
|
143
|
+
return {
|
|
144
|
+
enableMockPayments: config.enableMockPayments,
|
|
145
|
+
paymentAccountNumber: config.paymentAccountNumber,
|
|
146
|
+
paymentMode: config.paymentMode,
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
exports.getPaymentConfig = getPaymentConfig;
|
|
150
|
+
const getUIConfig = () => {
|
|
151
|
+
const config = (0, exports.getEnvironmentConfig)();
|
|
152
|
+
return {
|
|
153
|
+
showDebugInfo: config.showDebugInfo,
|
|
154
|
+
logLevel: config.logLevel,
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
exports.getUIConfig = getUIConfig;
|