Add API to get dns record
This commit is contained in:
@@ -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));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user