I have a platform that provides an e-commerce store creation service, and I use Hestia to manage domains and DNS. Anyone who owns a store can connect a domain via nameservers, and I use the command-line interface to create a request to link the domain to the store. But I’m concerned about the future if I have a large number of domain linking requests. What is the best way to ensure no problems and optimal performance: CLI or API?
Exmaple Code with node js using execSync Function to execute commands directly in the VPS when receiving a new linking request:
try {
//1:Create WEB Domain
const createWebDomainOutput = execSync(
`v-add-web-domain ${EnviromentsClass.HESTIA_CP_USER} ${createStoreDomainDto.domainName} ${EnviromentsClass.SERVER_IP}`,
{ encoding: "utf-8" }
);
if (createWebDomainOutput.toLowerCase().includes("error")) {
throw new BadRequestException(createWebDomainOutput);
}
} catch (error) {
throw new BadRequestException("Error in Creating Web Domain");
}
//2:Create DNS Domain
try {
const createDnsDomainOutput = execSync(
`v-add-dns-domain ${EnviromentsClass.HESTIA_CP_USER} ${createStoreDomainDto.domainName} ${EnviromentsClass.SERVER_IP} ${EnviromentsClass.SERVER_NS1} ${EnviromentsClass.SERVER_NS2}`,
{ encoding: "utf-8" }
);
if (createDnsDomainOutput.toLowerCase().includes("error")) {
throw new BadRequestException(createDnsDomainOutput);
}
} catch (error) {
throw new BadRequestException("Error in Creating Dns Domain");
}