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.
73 lines
2.9 KiB
JavaScript
73 lines
2.9 KiB
JavaScript
/**
|
||
* API Endpoints Test Script
|
||
*
|
||
* This script tests the multi-currency API endpoints
|
||
*/
|
||
|
||
const baseUrl = 'http://localhost:5000/api/financial';
|
||
|
||
async function testApiEndpoints() {
|
||
console.log('🌐 Testing Multi-Currency API Endpoints...\n');
|
||
|
||
try {
|
||
// Test 1: Get all currencies
|
||
console.log('1️⃣ Testing GET /api/financial/currencies');
|
||
const currenciesResponse = await fetch(`${baseUrl}/currencies`);
|
||
const currenciesData = await currenciesResponse.json();
|
||
|
||
if (currenciesData.success) {
|
||
console.log(`✅ Found ${currenciesData.data.length} currencies`);
|
||
currenciesData.data.slice(0, 3).forEach(currency => {
|
||
console.log(` - ${currency.name} (${currency.code})`);
|
||
});
|
||
} else {
|
||
console.log('❌ Failed to fetch currencies');
|
||
}
|
||
|
||
// Test 2: Get exchange rates
|
||
console.log('\n2️⃣ Testing GET /api/financial/exchange-rates');
|
||
const ratesResponse = await fetch(`${baseUrl}/exchange-rates`);
|
||
const ratesData = await ratesResponse.json();
|
||
|
||
if (ratesData.success) {
|
||
console.log(`✅ Found ${ratesData.data.length} exchange rates`);
|
||
ratesData.data.slice(0, 3).forEach(rate => {
|
||
console.log(` - ${rate.fromCurrency.code} → ${rate.toCurrency.code}: ${rate.rate}`);
|
||
});
|
||
} else {
|
||
console.log('❌ Failed to fetch exchange rates');
|
||
}
|
||
|
||
// Test 3: Test currency conversion
|
||
console.log('\n3️⃣ Testing GET /api/financial/convert');
|
||
const convertResponse = await fetch(`${baseUrl}/convert?amount=100&from=USD&to=EUR`);
|
||
const convertData = await convertResponse.json();
|
||
|
||
if (convertData.success) {
|
||
console.log(`✅ Currency conversion: ${convertData.data.originalAmount} ${convertData.data.fromCurrency} = ${convertData.data.convertedAmount} ${convertData.data.toCurrency}`);
|
||
} else {
|
||
console.log('❌ Failed to convert currency');
|
||
}
|
||
|
||
console.log('\n🎉 API endpoint tests completed!');
|
||
console.log('\n📋 Available Endpoints:');
|
||
console.log('✅ GET /api/financial/currencies - List currencies');
|
||
console.log('✅ GET /api/financial/exchange-rates - List exchange rates');
|
||
console.log('✅ GET /api/financial/convert - Convert currencies');
|
||
console.log('✅ POST /api/financial/currencies - Create currency (Admin)');
|
||
console.log('✅ POST /api/financial/exchange-rates - Create/update rate (Admin)');
|
||
console.log('✅ GET /api/financial/courses/:id/currency - Get course currency config');
|
||
console.log('✅ POST /api/financial/courses/:id/currency - Set course currency config');
|
||
|
||
} catch (error) {
|
||
console.error('❌ API test failed:', error.message);
|
||
console.log('\n💡 Make sure your CourseWorx server is running on http://localhost:5000');
|
||
}
|
||
}
|
||
|
||
// Run tests if this script is executed directly
|
||
if (require.main === module) {
|
||
testApiEndpoints();
|
||
}
|
||
|
||
module.exports = { testApiEndpoints };
|