add .prettierrc, and make prettier
This commit is contained in:
parent
3cd68f93e8
commit
1afddd9aae
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"bracketSpacing": true,
|
||||
"printWidth": 80,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"useTabs": true
|
||||
}
|
43
lib/index.js
43
lib/index.js
|
@ -30,14 +30,14 @@ module.exports.create = function(config) {
|
|||
form: {
|
||||
type: 'TXT',
|
||||
name: dnsPrefix,
|
||||
data: '"'+txt+'"', // vultr requires the TXT record wraped in quotes
|
||||
data: '"' + txt + '"', // vultr requires the TXT record wraped in quotes
|
||||
domain: config.domain,
|
||||
ttl: 300
|
||||
}
|
||||
}).then(function(resp) {
|
||||
if(resp.statusCode==200){
|
||||
if (resp.statusCode == 200) {
|
||||
return true;
|
||||
}else{
|
||||
} else {
|
||||
console.log(resp.statusCode);
|
||||
console.log(resp.body);
|
||||
throw new Error('record did not set. check subdomain, api key, etc');
|
||||
|
@ -53,24 +53,26 @@ module.exports.create = function(config) {
|
|||
|
||||
return request({
|
||||
method: 'GET',
|
||||
url: url+'?domain='+config.domain,
|
||||
url: url + '?domain=' + config.domain,
|
||||
// PROBLEM (fixed): Remember to set json: true (not need to JSON.parse)
|
||||
json: true,
|
||||
headers: {
|
||||
'API-Key': apiKey
|
||||
}
|
||||
}).then(function(resp) {
|
||||
if(resp.statusCode==200){
|
||||
})
|
||||
.then(function(resp) {
|
||||
if (resp.statusCode == 200) {
|
||||
resp = resp.body;
|
||||
console.log(resp);
|
||||
var entries =
|
||||
resp.filter(function(x) {
|
||||
var entries = resp.filter(function(x) {
|
||||
return x.type === 'TXT';
|
||||
});
|
||||
|
||||
var entry = entries.filter(function(x) {
|
||||
// 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];
|
||||
|
||||
if (entry) {
|
||||
|
@ -80,10 +82,11 @@ module.exports.create = function(config) {
|
|||
"Couldn't remove record. check subdomain, api key, etc"
|
||||
);
|
||||
}
|
||||
}else{
|
||||
throw new Error("record did not set. check subdomain, api key, etc");
|
||||
} else {
|
||||
throw new Error(
|
||||
'record did not set. check subdomain, api key, etc'
|
||||
);
|
||||
}
|
||||
|
||||
})
|
||||
.then(function(recordId) {
|
||||
var domainname = data.challenge.altname;
|
||||
|
@ -98,15 +101,17 @@ module.exports.create = function(config) {
|
|||
},
|
||||
form: {
|
||||
domain: config.domain,
|
||||
'RECORDID': recordId
|
||||
RECORDID: recordId
|
||||
}
|
||||
}).then(function(resp) {
|
||||
if(resp.statusCode==200){
|
||||
if (resp.statusCode == 200) {
|
||||
return true;
|
||||
}else{
|
||||
} else {
|
||||
console.log(resp.statusCode);
|
||||
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'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -122,7 +127,7 @@ module.exports.create = function(config) {
|
|||
|
||||
return request({
|
||||
method: 'GET',
|
||||
url: url+'?domain='+config.domain,
|
||||
url: url + '?domain=' + config.domain,
|
||||
json: true,
|
||||
headers: {
|
||||
'API-Key': apiKey
|
||||
|
@ -140,7 +145,9 @@ module.exports.create = function(config) {
|
|||
})[0];
|
||||
|
||||
if (entry) {
|
||||
return { dnsAuthorization: entry.data.substring(1, entry.data.length - 1)};
|
||||
return {
|
||||
dnsAuthorization: entry.data.substring(1, entry.data.length - 1)
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue