courseworx/backend/utils/getServerIP.js
mmabdalla 5477297914 v2.0.2 - Complete Plugin Architecture System and Multi-Currency Implementation
Major Features Added:
- Complete Plugin Architecture System with financial plugin
- Multi-currency support with exchange rates
- Course type system (online, classroom, hybrid)
- Attendance tracking and QR code scanning
- Classroom sessions management
- Course sections and content management
- Professional video player with authentication
- Secure media serving system
- Shopping cart and checkout system
- Financial dashboard and earnings tracking
- Trainee progress tracking
- User notes and assignments system

Backend Infrastructure:
- Plugin loader and registry system
- Multi-currency database models
- Secure media middleware
- Course access middleware
- Financial plugin with payment processing
- Database migrations for new features
- API endpoints for all new functionality

Frontend Components:
- Course management interface
- Content creation and editing
- Section management with drag-and-drop
- Professional video player
- QR scanner for attendance
- Shopping cart and checkout flow
- Financial dashboard
- Plugin management interface
- Trainee details and progress views

This represents a major evolution of CourseWorx from a basic LMS to a comprehensive educational platform with plugin architecture.
2025-09-14 04:20:37 +03:00

52 lines
1.4 KiB
JavaScript

const os = require('os');
/**
* Get the server's local IP address for network access
* @returns {string} The local IP address
*/
function getServerIP() {
const interfaces = os.networkInterfaces();
// Priority order: Wi-Fi, Ethernet, then any other non-internal interface
const priorityInterfaces = ['Wi-Fi', 'Ethernet', 'Local Area Connection'];
// First, try priority interfaces
for (const interfaceName of priorityInterfaces) {
if (interfaces[interfaceName]) {
for (const iface of interfaces[interfaceName]) {
if (iface.family === 'IPv4' && !iface.internal && !iface.address.startsWith('169.254.')) {
return iface.address;
}
}
}
}
// Then look for any non-internal IPv4 address (excluding APIPA)
for (const name of Object.keys(interfaces)) {
for (const iface of interfaces[name]) {
if (iface.family === 'IPv4' && !iface.internal && !iface.address.startsWith('169.254.')) {
return iface.address;
}
}
}
// Fallback to localhost if no network interface found
return 'localhost';
}
/**
* Get the full frontend URL for QR codes
* @param {number} port - The frontend port (default: 3000)
* @returns {string} The full frontend URL
*/
function getFrontendURL(port = 3000) {
const ip = getServerIP();
return `http://${ip}:${port}`;
}
module.exports = {
getServerIP,
getFrontendURL
};