whodis-mcp-server
Version:
Whodis MCP Server for checking the availability of domain names using WHOIS lookups.
50 lines (49 loc) • 2.44 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const domain_availability_service_js_1 = __importDefault(require("../services/domain-availability.service.js"));
const logger_util_js_1 = require("../utils/logger.util.js");
const error_handler_util_js_1 = require("../utils/error-handler.util.js");
const controllerLogger = logger_util_js_1.Logger.forContext('controllers/domain-availability.controller.ts');
/**
* @namespace DomainAvailabilityController
* @description Controller for handling domain availability checks.
*/
/**
* Checks domain availability and returns a formatted response.
*
* @function check
* @memberof DomainAvailabilityController
* @param {string[]} domains - An array of domain names.
* @returns {Promise<ControllerResponse>} A promise resolving to the standard controller response containing the availability results as JSON.
* @throws {McpError} Propagates errors from the service layer, handled by `handleControllerError`.
*/
async function check(domains) {
const methodLogger = controllerLogger.forMethod('check');
methodLogger.debug(`Checking availability for ${domains.length} domains.`);
try {
const availabilityResult = await domain_availability_service_js_1.default.check(domains);
// Format the result as a JSON string for the response content
const formattedContent = JSON.stringify(availabilityResult, null, 2);
methodLogger.debug('Domain availability check successful.');
return {
content: formattedContent,
// No pagination needed for this operation
};
}
catch (error) {
// Use the standardized error handler
// `handleControllerError` throws the error, so we don't need to return here in the catch block.
// However, the function signature requires a return type, so TS might complain.
// Let's explicitly return the result of handleControllerError which throws.
return (0, error_handler_util_js_1.handleControllerError)(error, {
entityType: 'Domain Availability',
operation: 'checking',
source: 'controllers/domain-availability.controller.ts@check',
additionalInfo: { domainCount: domains.length },
});
}
}
exports.default = { check };
;