57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Test script for /process endpoint
|
|
*
|
|
* This verifies the implementation is correct without requiring
|
|
* the service to be running. It checks:
|
|
* - Type exports are available
|
|
* - Client has process() method
|
|
* - Request structure matches implementation
|
|
*/
|
|
|
|
import { ImageProcessingClient } from './services/imajin-processing/client/dist/index.mjs';
|
|
|
|
console.log('✓ Successfully imported ImageProcessingClient');
|
|
|
|
// Check that the client has the process method
|
|
const client = new ImageProcessingClient({ baseUrl: 'http://localhost:8004' });
|
|
|
|
if (typeof client.process !== 'function') {
|
|
console.error('✗ Client missing process() method');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('✓ Client has process() method');
|
|
|
|
// Check method signature
|
|
const processMethod = client.process.toString();
|
|
if (!processMethod.includes('image') || !processMethod.includes('mimeType') || !processMethod.includes('operations')) {
|
|
console.error('✗ process() method has wrong signature');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('✓ process() method has correct signature');
|
|
|
|
console.log('\n==============================================');
|
|
console.log('All implementation checks passed! ✓');
|
|
console.log('==============================================\n');
|
|
|
|
console.log('Example usage:');
|
|
console.log(`
|
|
const result = await client.process(
|
|
base64ImageData,
|
|
'image/png',
|
|
['optimize', 'convert-webp', 'derivatives'],
|
|
'hero'
|
|
);
|
|
|
|
// Result contains:
|
|
// - success: boolean
|
|
// - processed: ProcessedImage (WebP format)
|
|
// - derivatives: { hero_full: {...}, hero_lg: {...}, ... }
|
|
// - metadata: { operationsApplied, totalSize, processingTimeMs }
|
|
`);
|
|
|
|
console.log('To test end-to-end, start the processing service:');
|
|
console.log(' cd services/imajin-processing/service');
|
|
console.log(' npm run dev\n');
|