Files
inventory-barcode-system/config/production.js

79 lines
2.5 KiB
JavaScript

/**
* Production Environment Configuration
* This file contains production-specific settings and environment variable handling
*/
const path = require('path');
module.exports = {
// Server Configuration
server: {
port: process.env.PORT || 3000,
host: process.env.HOST || '0.0.0.0',
environment: process.env.NODE_ENV || 'production',
requestTimeout: parseInt(process.env.REQUEST_TIMEOUT) || 30000
},
// Database Configuration
database: {
path: process.env.DATABASE_PATH || './inventory.db',
backupPath: process.env.DATABASE_BACKUP_PATH || './data/backups',
backupInterval: parseInt(process.env.DATABASE_BACKUP_INTERVAL) || 3600000, // 1 hour
queryTimeout: parseInt(process.env.QUERY_TIMEOUT) || 5000
},
// File Upload Configuration
upload: {
maxSize: parseInt(process.env.UPLOAD_MAX_SIZE) || 10 * 1024 * 1024, // 10MB
allowedTypes: process.env.UPLOAD_ALLOWED_TYPES?.split(',') || [
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-excel'
],
tempDir: process.env.TEMP_DIR || './data/temp'
},
// Export Configuration
export: {
dir: process.env.EXPORT_DIR || './data/exports',
retentionDays: parseInt(process.env.EXPORT_RETENTION_DAYS) || 30
},
// Logging Configuration
logging: {
level: process.env.LOG_LEVEL || 'info',
dir: process.env.LOG_DIR || './logs',
maxSize: process.env.LOG_MAX_SIZE || '10m',
maxFiles: process.env.LOG_MAX_FILES || '14d'
},
// Security Configuration
security: {
corsOrigin: process.env.CORS_ORIGIN || '*',
helmetCspEnabled: process.env.HELMET_CSP_ENABLED === 'true',
rateLimitEnabled: process.env.RATE_LIMIT_ENABLED === 'true',
rateLimitMax: parseInt(process.env.RATE_LIMIT_MAX) || 100
},
// Performance Configuration
performance: {
cacheTtl: parseInt(process.env.CACHE_TTL) || 300000, // 5 minutes
maxConcurrentImports: parseInt(process.env.MAX_CONCURRENT_IMPORTS) || 3
},
// Backup Configuration
backup: {
enabled: process.env.BACKUP_ENABLED === 'true',
schedule: process.env.BACKUP_SCHEDULE || '0 2 * * *', // Daily at 2 AM
retentionDays: parseInt(process.env.BACKUP_RETENTION_DAYS) || 30
},
// Validate required environment variables
validate() {
const required = [];
const missing = required.filter(key => !process.env[key]);
if (missing.length > 0) {
throw new Error(`Missing required environment variables: ${missing.join(', ')}`);
}
}
};