@valexe-technologies/lookup.services
Version:
Business Services for Lookup
43 lines • 1.79 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DomainServices = void 0;
const puppeteer_1 = __importDefault(require("puppeteer"));
const _1 = require("./");
const WHOIS_DOMAIN_REGISTRAR = new _1.GoDaddyWhoIsRegisrar();
const SUPPORTED_DOMAIN_REGISTRARS = {
['godaddy']: new _1.GoDaddyDomainRegistrar(),
['bigrock']: new _1.BigRockDomainRegistrar(),
['nettigritty']: new _1.NettigrittyDomainRegistrar(),
['2gb hosting']: new _1.TwoGBHostingDomainRegistrar()
};
class DomainServices {
constructor() {
this.domainRegistrars = [];
this.browser = null;
}
async init(headLess = true) {
this.domainRegistrars = Object.keys(SUPPORTED_DOMAIN_REGISTRARS)
.map((key) => SUPPORTED_DOMAIN_REGISTRARS[key].properties);
this.browser = await puppeteer_1.default.launch({
headless: headLess
});
}
async isDomainAvailable(domainNameWithTLD) {
return await WHOIS_DOMAIN_REGISTRAR.isDomainAvailable(this.browser, domainNameWithTLD);
}
async domainRegistrarsByCurrency(currencyCode) {
return await this.domainRegistrars.filter((registrar) => registrar.currencyCodes.includes(currencyCode));
}
async domainPrice(registrar, domainNameWithTLD, currency) {
let domainRegistrar = SUPPORTED_DOMAIN_REGISTRARS[registrar.toLowerCase()];
if (domainRegistrar !== undefined) {
return await domainRegistrar.getDomainPrice(this.browser, domainNameWithTLD, currency);
}
return null;
}
}
exports.DomainServices = DomainServices;
//# sourceMappingURL=domainServices.js.map