/** * Server Configuration * Central configuration for all backend constants and settings */ const path = require('path'); const config = { // Server Settings server: { port: process.env.PORT || 3000, host: process.env.HOST || '0.0.0.0', // Bind to all interfaces env: process.env.NODE_ENV || 'development' }, // Database Settings database: { path: path.join(__dirname, '../database/datacenter.db'), // Enable WAL mode for better concurrency walMode: true, // Enable foreign keys foreignKeys: true, // Busy timeout in ms busyTimeout: 5000 }, // Rack Configuration rack: { // Default dimensions in pixels defaultWidth: 520, defaultHeight: 1485, // Number of U slots slots: 42, // Grid spacing gridHorizontal: 600, gridVertical: 1585 }, // Device Configuration device: { // Default device dimensions defaultHeight: 32, defaultSpacing: 2, // Margins within rack margin: { top: 10, right: 10, bottom: 10, left: 10 }, // Physical view width physicalWidth: 500, // Logical view width logicalWidth: 120 }, // Validation Rules validation: { project: { nameMinLength: 1, nameMaxLength: 100, descriptionMaxLength: 500 }, rack: { nameMinLength: 1, nameMaxLength: 50, maxPerProject: 1000 }, device: { nameMinLength: 1, nameMaxLength: 50, minRackUnits: 1, maxRackUnits: 42 }, connection: { maxWaypoints: 20 } }, // API Settings api: { // Request size limits jsonLimit: '10mb', // Enable CORS (set to true if frontend is on different domain) cors: false, // Rate limiting (requests per minute per IP) rateLimit: { enabled: false, windowMs: 60000, // 1 minute max: 100 // 100 requests per minute } }, // Logging logging: { enabled: true, level: process.env.LOG_LEVEL || 'info', // debug, info, warn, error format: 'combined' // Morgan format }, // Default Device Types (seed data) deviceTypes: [ { name: 'Switch 24-Port', portsCount: 24, color: '#4A90E2', rackUnits: 1 }, { name: 'Switch 48-Port', portsCount: 48, color: '#5CA6E8', rackUnits: 1 }, { name: 'Router', portsCount: 8, color: '#E27D60', rackUnits: 1 }, { name: 'Firewall', portsCount: 6, color: '#E8A87C', rackUnits: 1 }, { name: 'Server 1U', portsCount: 4, color: '#41B3A3', rackUnits: 1 }, { name: 'Server 2U', portsCount: 4, color: '#41B3A3', rackUnits: 2 }, { name: 'Server 4U', portsCount: 8, color: '#38A169', rackUnits: 4 }, { name: 'Storage', portsCount: 8, color: '#38A169', rackUnits: 2 }, { name: 'Patch Panel 24', portsCount: 24, color: '#9B59B6', rackUnits: 1 }, { name: 'Patch Panel 48', portsCount: 48, color: '#A569BD', rackUnits: 1 } ] }; module.exports = config;