add .prettierrc, and make prettier

This commit is contained in:
AJ ONeal 2019-06-13 03:53:54 -06:00
parent 3cd68f93e8
commit 1afddd9aae
4 changed files with 80 additions and 65 deletions

8
.prettierrc Normal file
View File

@ -0,0 +1,8 @@
{
"bracketSpacing": true,
"printWidth": 80,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": true
}

View File

@ -59,18 +59,20 @@ module.exports.create = function(config) {
headers: { headers: {
'API-Key': apiKey 'API-Key': apiKey
} }
}).then(function(resp) { })
.then(function(resp) {
if (resp.statusCode == 200) { if (resp.statusCode == 200) {
resp = resp.body; resp = resp.body;
console.log(resp); console.log(resp);
var entries = var entries = resp.filter(function(x) {
resp.filter(function(x) {
return x.type === 'TXT'; return x.type === 'TXT';
}); });
var entry = entries.filter(function(x) { var entry = entries.filter(function(x) {
// vultr wraps the TXT record in double quotes // vultr wraps the TXT record in double quotes
return x.data.substring(1, x.data.length - 1) === ch.dnsAuthorization; return (
x.data.substring(1, x.data.length - 1) === ch.dnsAuthorization
);
})[0]; })[0];
if (entry) { if (entry) {
@ -81,9 +83,10 @@ module.exports.create = function(config) {
); );
} }
} else { } else {
throw new Error("record did not set. check subdomain, api key, etc"); throw new Error(
'record did not set. check subdomain, api key, etc'
);
} }
}) })
.then(function(recordId) { .then(function(recordId) {
var domainname = data.challenge.altname; var domainname = data.challenge.altname;
@ -98,7 +101,7 @@ module.exports.create = function(config) {
}, },
form: { form: {
domain: config.domain, domain: config.domain,
'RECORDID': recordId RECORDID: recordId
} }
}).then(function(resp) { }).then(function(resp) {
if (resp.statusCode == 200) { if (resp.statusCode == 200) {
@ -106,7 +109,9 @@ module.exports.create = function(config) {
} else { } else {
console.log(resp.statusCode); console.log(resp.statusCode);
console.log(resp.body); console.log(resp.body);
throw new Error("record did not remove. check subdomain, api key, etc"); throw new Error(
'record did not remove. check subdomain, api key, etc'
);
} }
}); });
}); });
@ -140,7 +145,9 @@ module.exports.create = function(config) {
})[0]; })[0];
if (entry) { if (entry) {
return { dnsAuthorization: entry.data.substring(1, entry.data.length - 1)}; return {
dnsAuthorization: entry.data.substring(1, entry.data.length - 1)
};
} else { } else {
return null; return null;
} }