pi-kiosk-shared 1.0.5 → 1.0.7

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
- // Simple environment configuration
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
- apiUrl: getEnvVar('REACT_APP_API_URL', 'http://localhost:3015'),
38
- wsUrl: getEnvVar('REACT_APP_WS_URL', 'ws://localhost:3015'),
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
- apiUrl: getEnvVar('REACT_APP_API_URL', 'https://kiosk-prod.railway.app'),
47
- wsUrl: getEnvVar('REACT_APP_WS_URL', 'wss://kiosk-prod.railway.app'),
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
  }
@@ -86,3 +119,32 @@ const isDevelopment = () => (0, exports.getCurrentEnvironment)() === 'developmen
86
119
  exports.isDevelopment = isDevelopment;
87
120
  const isProduction = () => (0, exports.getCurrentEnvironment)() === 'production';
88
121
  exports.isProduction = isProduction;
122
+ // Utility functions for easy access to service URLs
123
+ const getBackendUrl = () => (0, exports.getEnvironmentConfig)().backendUrl;
124
+ exports.getBackendUrl = getBackendUrl;
125
+ const getKioskUrl = () => (0, exports.getEnvironmentConfig)().kioskUrl;
126
+ exports.getKioskUrl = getKioskUrl;
127
+ const getAdminUrl = () => (0, exports.getEnvironmentConfig)().adminUrl;
128
+ exports.getAdminUrl = getAdminUrl;
129
+ const getApiUrl = () => (0, exports.getEnvironmentConfig)().apiUrl;
130
+ exports.getApiUrl = getApiUrl;
131
+ const getWsUrl = () => (0, exports.getEnvironmentConfig)().wsUrl;
132
+ exports.getWsUrl = getWsUrl;
133
+ // Service-specific configuration helpers
134
+ const getPaymentConfig = () => {
135
+ const config = (0, exports.getEnvironmentConfig)();
136
+ return {
137
+ enableMockPayments: config.enableMockPayments,
138
+ paymentAccountNumber: config.paymentAccountNumber,
139
+ paymentMode: config.paymentMode,
140
+ };
141
+ };
142
+ exports.getPaymentConfig = getPaymentConfig;
143
+ const getUIConfig = () => {
144
+ const config = (0, exports.getEnvironmentConfig)();
145
+ return {
146
+ showDebugInfo: config.showDebugInfo,
147
+ logLevel: config.logLevel,
148
+ };
149
+ };
150
+ exports.getUIConfig = getUIConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-kiosk-shared",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "private": false,
5
5
  "description": "Shared components and utilities for Pi Kiosk system",
6
6
  "keywords": [