Add API to get dns record

This commit is contained in:
Girish Ramakrishnan
2019-09-19 15:10:27 -07:00
parent 1974314c1f
commit b05a9ce064
3 changed files with 19 additions and 1 deletions
+17
View File
@@ -7,6 +7,8 @@ exports = module.exports = {
update: update,
del: del,
getDnsRecord: getDnsRecord,
verifyDomainLock: verifyDomainLock
};
@@ -152,3 +154,18 @@ function del(req, res, next) {
next(new HttpSuccess(204));
});
}
function getDnsRecord(req, res, next) {
assert.strictEqual(typeof req.params.domains, 'string');
if (!('subdomain' in req.query)) return next(new HttpError(400, 'subdomain is required'));
if (!('type' in req.query)) return next(new HttpError(400, 'type is required'));
domains.getDnsRecords(req.query.subdomain, req.params.domain, req.query.type, function (error, result) {
if (error && error.reason === DomainsError.NOT_FOUND) return next(new HttpError(404, error.message));
if (error && error.reason === DomainsError.EXTERNAL_ERROR) return next(new HttpError(424, error.message));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, result));
});
}