A Point of Sale (POS) application built with React Native.
This project uses environment configuration for different settings and API endpoints.
The configuration is located in the config/ directory:
env.example.js- Example configuration file with all available optionsenv.js- Your actual environment configuration (not tracked in git)index.js- Centralized configuration object and helper functions
-
Copy
env.example.jstoenv.js:cp config/env.example.js config/env.js
-
Update the values in
config/env.jsaccording to your environment
API_BASE_URL- Base URL for your APIAPI_TIMEOUT- Request timeout in milliseconds
APP_NAME- Application nameAPP_VERSION- Application versionAPP_ENVIRONMENT- Environment (development, staging, production)
TOKEN_STORAGE_KEY- Key for storing authentication tokenUSER_STORAGE_KEY- Key for storing user data
CACHE_DIRECTORY- Directory for caching filesPROFILE_PICTURE_CACHE- Subdirectory for profile pictures
TOAST_DURATION- Toast message duration in millisecondsTOAST_POSITION- Toast message position
DEBUG_MODE- Enable/disable debug loggingLOG_LEVEL- Logging level (debug, info, warn, error)
Import the configuration in your components:
import { CONFIG, getApiUrl, log, isDevelopment } from '../config';
// Use configuration values
const apiUrl = getApiUrl('login');
const isDev = isDevelopment();
// Log messages
log('This is a debug message', 'debug');export const ENV_CONFIG = {
API_BASE_URL: 'http://10.0.2.2:8000/api',
APP_ENVIRONMENT: 'development',
DEBUG_MODE: true,
LOG_LEVEL: 'debug',
};export const ENV_CONFIG = {
API_BASE_URL: 'https://your-production-api.com/api',
APP_ENVIRONMENT: 'production',
DEBUG_MODE: false,
LOG_LEVEL: 'error',
};- Never commit
config/env.jsto version control - Use different API URLs for different environments
- Disable debug mode in production
- Use secure storage keys that are environment-specific