make Prettier
This commit is contained in:
		
							parent
							
								
									c33c42899f
								
							
						
					
					
						commit
						393d25621c
					
				
							
								
								
									
										58
									
								
								lib/index.js
									
									
									
									
									
								
							
							
						
						
									
										58
									
								
								lib/index.js
									
									
									
									
									
								
							| @ -11,7 +11,7 @@ var defaults = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| module.exports.create = function(config) { | module.exports.create = function(config) { | ||||||
| 	var baseUrl = (config.baseUrl || defaults.baseUrl); | 	var baseUrl = config.baseUrl || defaults.baseUrl; | ||||||
| 	var apiKey = config.key || config.apiKey; | 	var apiKey = config.key || config.apiKey; | ||||||
| 	var apiSecret = config.secret || config.apiSecret; | 	var apiSecret = config.secret || config.apiSecret; | ||||||
| 
 | 
 | ||||||
| @ -22,7 +22,7 @@ module.exports.create = function(config) { | |||||||
| 			method: method, | 			method: method, | ||||||
| 			url: baseUrl + path, | 			url: baseUrl + path, | ||||||
| 			headers: { | 			headers: { | ||||||
| 				'Authorization': auth | 				Authorization: auth | ||||||
| 			}, | 			}, | ||||||
| 			json: form || true | 			json: form || true | ||||||
| 		}); | 		}); | ||||||
| @ -45,7 +45,6 @@ module.exports.create = function(config) { | |||||||
| 				return resp.body.map(function(x) { | 				return resp.body.map(function(x) { | ||||||
| 					return x.domain; | 					return x.domain; | ||||||
| 				}); | 				}); | ||||||
| 
 |  | ||||||
| 			}); | 			}); | ||||||
| 		}, | 		}, | ||||||
| 		set: function(data) { | 		set: function(data) { | ||||||
| @ -53,37 +52,43 @@ module.exports.create = function(config) { | |||||||
| 			var txt = ch.dnsAuthorization; | 			var txt = ch.dnsAuthorization; | ||||||
| 			// If the domain to be verified is
 | 			// If the domain to be verified is
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 			// optional params commented
 | 			// optional params commented
 | ||||||
| 			var records = [ | 			var records = [ | ||||||
| 				{ | 				{ | ||||||
| 					"data": txt, | 					data: txt, | ||||||
| 					"name": ch.dnsPrefix, | 					name: ch.dnsPrefix, | ||||||
| 					// "port": 0,
 | 					// "port": 0,
 | ||||||
| 					// "priority": 0,
 | 					// "priority": 0,
 | ||||||
| 					// "protocol": "string",
 | 					// "protocol": "string",
 | ||||||
| 					// "service": "string",
 | 					// "service": "string",
 | ||||||
| 					"ttl": 600, | 					ttl: 600, | ||||||
| 					"type": "TXT", | 					type: 'TXT' | ||||||
| 					// "weight": 0
 | 					// "weight": 0
 | ||||||
| 				} | 				} | ||||||
| 			]; | 			]; | ||||||
| 
 | 
 | ||||||
| 			return api('PATCH', 'domains/'+ch.dnsZone+'/records', records).then(function(resp) { | 			return api('PATCH', 'domains/' + ch.dnsZone + '/records', records).then( | ||||||
|  | 				function(resp) { | ||||||
| 					if (200 !== resp.statusCode) { | 					if (200 !== resp.statusCode) { | ||||||
| 						console.error(resp.statusCode); | 						console.error(resp.statusCode); | ||||||
| 						console.error(resp.body); | 						console.error(resp.body); | ||||||
| 					throw new Error('record did not set. check subdomain, api key, etc'); | 						throw new Error( | ||||||
|  | 							'record did not set. check subdomain, api key, etc' | ||||||
|  | 						); | ||||||
| 					} | 					} | ||||||
| 
 | 
 | ||||||
| 					return true; | 					return true; | ||||||
| 			}); | 				} | ||||||
|  | 			); | ||||||
| 		}, | 		}, | ||||||
| 		remove: function(data) { | 		remove: function(data) { | ||||||
| 			var ch = data.challenge; | 			var ch = data.challenge; | ||||||
| 
 | 
 | ||||||
| 			// get all domain records of type or name
 | 			// get all domain records of type or name
 | ||||||
| 			return api('GET', 'domains/'+ch.dnsZone+'/records/TXT/'+ch.dnsPrefix) | 			return api( | ||||||
|  | 				'GET', | ||||||
|  | 				'domains/' + ch.dnsZone + '/records/TXT/' + ch.dnsPrefix | ||||||
|  | 			) | ||||||
| 				.then(function(resp) { | 				.then(function(resp) { | ||||||
| 					if (200 !== resp.statusCode) { | 					if (200 !== resp.statusCode) { | ||||||
| 						console.error(resp.statusCode); | 						console.error(resp.statusCode); | ||||||
| @ -95,11 +100,12 @@ module.exports.create = function(config) { | |||||||
| 					// filter all TXT records without record to remove
 | 					// filter all TXT records without record to remove
 | ||||||
| 					for (let i = 0; i < resp.body.length; i++) { | 					for (let i = 0; i < resp.body.length; i++) { | ||||||
| 						if (resp.body[i]['data'] !== ch.dnsAuthorization) { | 						if (resp.body[i]['data'] !== ch.dnsAuthorization) { | ||||||
| 							newEntries.push(resp.body[i]) | 							newEntries.push(resp.body[i]); | ||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| 					return newEntries; | 					return newEntries; | ||||||
| 				}).then(function(newRecords) { | 				}) | ||||||
|  | 				.then(function(newRecords) { | ||||||
| 					// godaddy doesn't provide an endpoint for a single record removal
 | 					// godaddy doesn't provide an endpoint for a single record removal
 | ||||||
| 					// but provides this endpoint to replace all records of a given type
 | 					// but provides this endpoint to replace all records of a given type
 | ||||||
| 					// https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplaceType
 | 					// https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplaceType
 | ||||||
| @ -109,29 +115,35 @@ module.exports.create = function(config) { | |||||||
| 
 | 
 | ||||||
| 					if (!newRecords.length) { | 					if (!newRecords.length) { | ||||||
| 						newRecords.push({ | 						newRecords.push({ | ||||||
| 							"data": 'free_to_delete', | 							data: 'free_to_delete', | ||||||
| 							"name": 'remove_placeholder', | 							name: 'remove_placeholder', | ||||||
| 							"ttl": 600 | 							ttl: 600 | ||||||
| 
 |  | ||||||
| 						}); | 						}); | ||||||
| 					} | 					} | ||||||
| 
 | 
 | ||||||
| 					// update - overwrite all type and name records under domain
 | 					// update - overwrite all type and name records under domain
 | ||||||
| 					return api('PUT', 'domains/'+ch.dnsZone+'/records/TXT', newRecords).then(function(resp) { | 					return api( | ||||||
|  | 						'PUT', | ||||||
|  | 						'domains/' + ch.dnsZone + '/records/TXT', | ||||||
|  | 						newRecords | ||||||
|  | 					).then(function(resp) { | ||||||
| 						if (200 !== resp.statusCode) { | 						if (200 !== resp.statusCode) { | ||||||
| 							console.error(resp.statusCode); | 							console.error(resp.statusCode); | ||||||
| 							console.error(resp.body); | 							console.error(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' | ||||||
|  | 							); | ||||||
| 						} | 						} | ||||||
| 						return true; | 						return true; | ||||||
| 					}); | 					}); | ||||||
| 				}); | 				}); | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 		}, | 		}, | ||||||
| 		get: function(data) { | 		get: function(data) { | ||||||
| 			var ch = data.challenge; | 			var ch = data.challenge; | ||||||
| 			return api('GET', 'domains/'+ch.dnsZone+'/records/TXT/'+ch.dnsPrefix).then(function(resp) { | 			return api( | ||||||
|  | 				'GET', | ||||||
|  | 				'domains/' + ch.dnsZone + '/records/TXT/' + ch.dnsPrefix | ||||||
|  | 			).then(function(resp) { | ||||||
| 				resp = resp.body; | 				resp = resp.body; | ||||||
| 
 | 
 | ||||||
| 				var entry = null; | 				var entry = null; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user