qapinterface
Version:
Comprehensive API utilities for Node.js applications including authentication, security, request processing, and response handling with zero external dependencies
24 lines (22 loc) • 668 B
JavaScript
/**
* Async Service Validator
* Single Responsibility: Validate services asynchronously ONLY
*/
/**
* Validates a service asynchronously.
* @param {function} serviceFunction - The service function to validate.
* @param {*} input - Input to pass to the service.
* @param {object} [options={}] - Validation options.
* @returns {Promise<object>} - Validation result.
*/
async function validateServiceAsync(serviceFunction, input, options = {}) {
try {
const result = await serviceFunction(input);
return { valid: true, result };
} catch (error) {
return { valid: false, error: error.message };
}
}
module.exports = {
validateServiceAsync
};