-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const xml = require('xml'); | ||
Check failure on line 1 in modules/api/location.js Codeac.io / Codeac Code Quality
|
||
const yaml = require('yaml'); | ||
|
||
class Location { | ||
constructor(data) { | ||
this.address = { | ||
full: data.address.full || '', | ||
houseNumber: data.address.houseNumber || '', | ||
street: data.address.street || '', | ||
city: data.address.city || '', | ||
region: data.address.region || '', | ||
country: data.address.country || '', | ||
postalCode: data.address.postalCode || '', | ||
}; | ||
this.pluscode = data.pluscode || ''; | ||
this.coords = { | ||
lat: data.coords.lat || 0, | ||
lng: data.coords.lng || 0, | ||
}; | ||
} | ||
get JSON() { | ||
return JSON.stringify({ | ||
address: this.address, | ||
pluscode: this.pluscode, | ||
coords: this.coords, | ||
}); | ||
} | ||
get XML() { | ||
return xml({ | ||
address: [ | ||
{ full: this.address.full }, | ||
{ houseNumber: this.address.houseNumber }, | ||
{ street: this.address.street }, | ||
{ city: this.address.city }, | ||
{ region: this.address.region }, | ||
{ country: this.address.country }, | ||
{ postalCode: this.address.postalCode }, | ||
], | ||
pluscode: this.pluscode, | ||
coords: this.coords, | ||
}); | ||
} | ||
get YAML() { | ||
return yaml.stringify({ | ||
address: this.address, | ||
pluscode: this.pluscode, | ||
coords: this.coords, | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Location; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const xml = require('xml'); | ||
Check failure on line 1 in modules/api/phone.js Codeac.io / Codeac Code Quality
|
||
const yaml = require('yaml'); | ||
|
||
class Phone { | ||
constructor(data) { | ||
this.status = data.status || 'error'; | ||
this.phone = data.phone || ''; | ||
this.phoneValid = data.phone_valid || false; | ||
this.phoneType = data.phone_type || ''; | ||
this.phoneRegion = data.phone_region || ''; | ||
this.country = data.country || ''; | ||
this.countryCode = data.country_code || ''; | ||
this.countryPrefix = data.country_prefix || ''; | ||
this.internationalNumber = data.international_number || ''; | ||
this.localNumber = data.local_number || ''; | ||
this.e164 = data.e164 || ''; | ||
this.carrier = data.carrier || ''; | ||
} | ||
get JSON() { | ||
return JSON.stringify({ | ||
status: this.status, | ||
phone: this.phone, | ||
phoneValid: this.phoneValid, | ||
phoneType: this.phoneType, | ||
phoneRegion: this.phoneRegion, | ||
country: this.country, | ||
countryCode: this.countryCode, | ||
countryPrefix: this.countryPrefix, | ||
internationalNumber: this.internationalNumber, | ||
localNumber: this.localNumber, | ||
e164: this.e164, | ||
carrier: this.carrier, | ||
}); | ||
} | ||
get XML() { | ||
return xml({ | ||
Check warning on line 36 in modules/api/phone.js Codeac.io / Codeac Code QualityCodeDuplication
|
||
status: this.status, | ||
phone: this.phone, | ||
phoneValid: this.phoneValid, | ||
phoneType: this.phoneType, | ||
phoneRegion: this.phoneRegion, | ||
country: this.country, | ||
countryCode: this.countryCode, | ||
countryPrefix: this.countryPrefix, | ||
internationalNumber: this.internationalNumber, | ||
localNumber: this.localNumber, | ||
e164: this.e164, | ||
carrier: this.carrier, | ||
}); | ||
} | ||
get YAML() { | ||
return yaml.stringify({ | ||
status: this.status, | ||
phone: this.phone, | ||
phoneValid: this.phoneValid, | ||
phoneType: this.phoneType, | ||
phoneRegion: this.phoneRegion, | ||
country: this.country, | ||
countryCode: this.countryCode, | ||
countryPrefix: this.countryPrefix, | ||
internationalNumber: this.internationalNumber, | ||
localNumber: this.localNumber, | ||
e164: this.e164, | ||
carrier: this.carrier, | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Phone; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const xml = require('xml'); | ||
Check failure on line 1 in modules/api/quote.js Codeac.io / Codeac Code Quality
|
||
const yaml = require('yaml'); | ||
|
||
class Quote { | ||
constructor(data) { | ||
this.quotes = data.quote; | ||
this.author = data.author; | ||
this.tags = data.tags; | ||
} | ||
get JSON() { | ||
return JSON.stringify({ | ||
quotes: this.quotes, | ||
author: this.author, | ||
tags: this.tags, | ||
}); | ||
} | ||
get XML() { | ||
return xml({ | ||
quotes: this.quotes, | ||
author: this.author, | ||
tags: this.tags, | ||
}); | ||
} | ||
get YAML() { | ||
return yaml.stringify({ | ||
quotes: this.quotes, | ||
author: this.author, | ||
tags: this.tags, | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Quote; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
/* eslint-disable id-length */ | ||
Check failure on line 1 in modules/api/whois.js Codeac.io / Codeac Code Quality
|
||
const xml = require('xml'); | ||
const yaml = require('yaml'); | ||
|
||
class Contact { | ||
constructor(data) { | ||
this.name = data.name || 'Unknown'; | ||
this.organization = data.organization || 'Unknown'; | ||
this.street = data.street || 'Unknown'; | ||
this.city = data.city || 'Unknown'; | ||
this.state = data.state || 'Unknown'; | ||
this.postalCode = data.postalCode || 'Unknown'; | ||
this.country = data.country || 'Unknown'; | ||
this.phone = data.phone || 'Unknown'; | ||
this.fax = data.fax || 'Unknown'; | ||
this.email = data.email || 'Unknown'; | ||
} | ||
get JSON() { | ||
return { | ||
name: this.name, | ||
organization: this.organization, | ||
street: this.street, | ||
city: this.city, | ||
state: this.state, | ||
postalCode: this.postalCode, | ||
country: this.country, | ||
phone: this.phone, | ||
fax: this.fax, | ||
email: this.email, | ||
}; | ||
} | ||
get XML() { | ||
return [ | ||
{ name: this.name }, | ||
{ organization: this.organization }, | ||
{ street: this.street }, | ||
{ city: this.city }, | ||
{ state: this.state }, | ||
{ postalCode: this.postalCode }, | ||
{ country: this.country }, | ||
{ phone: this.phone }, | ||
{ fax: this.fax }, | ||
{ email: this.email }, | ||
]; | ||
} | ||
} | ||
|
||
|
||
|
||
class DNS { | ||
constructor(data) { | ||
this.SOA = data.SOA || {}; | ||
this.A = data.A || ''; | ||
this.CAA = data.CAA || []; | ||
this.CNAME = data.CNAME || ''; | ||
this.SRV = data.SRV || []; | ||
this.AAAA = data.AAAA || ''; | ||
this.PTR = data.PTR || []; | ||
this.TXT = data.TXT || []; | ||
this.NS = data.NS || []; | ||
this.MX = data.MX || []; | ||
} | ||
get JSON() { | ||
return { | ||
SOA: this.SOA, | ||
A: this.A, | ||
CAA: this.CAA, | ||
CNAME: this.CNAME, | ||
SRV: this.SRV, | ||
AAAA: this.AAAA, | ||
PTR: this.PTR, | ||
TXT: this.TXT, | ||
NS: this.NS, | ||
MX: this.MX, | ||
}; | ||
} | ||
get XML() { | ||
return xml(this.XMLData); | ||
} | ||
get XMLData() { | ||
return [ | ||
{ | ||
SOA: [ | ||
{ nsname: this.SOA.nsname }, | ||
{ serial: this.SOA.serial }, | ||
{ expire: this.SOA.expire }, | ||
{ minttl: this.SOA.minttl }, | ||
{ retry: this.SOA.retry }, | ||
{ refresh: this.SOA.refresh }, | ||
{ hostmaster: this.SOA.hostmaster }, | ||
], | ||
}, | ||
{ A: this.A }, | ||
{ | ||
CAA: this.CAA.map(rec => ( | ||
rec.iodef | ||
? { iodef: rec.iodef } | ||
: { main: rec.main, wild: rec.wild, issuer: rec.issuer } | ||
)), | ||
}, | ||
{ CNAME: this.CNAME }, | ||
{ SRV: this.SRV.map(rec => ({ record: rec })) }, | ||
{ AAAA: this.AAAA }, | ||
{ PTR: this.PTR.map(rec => ({ record: rec })) }, | ||
{ TXT: this.TXT.map(rec => ({ record: rec })) }, | ||
{ NS: this.NS.map(rec => ({ record: rec })) }, | ||
{ MX: this.MX.map(rec => ({ priority: rec.priority, exchange: rec.exchange })) }, | ||
]; | ||
} | ||
get YAML() { | ||
return yaml.stringify(this.JSON); | ||
} | ||
} | ||
|
||
class WHOIS { | ||
constructor(data) { | ||
this.expirationDate = data.expirationDate || 'Unknown'; | ||
this.billing = new Contact(data.billing); | ||
this.registrar = data.registrar || 'Unknown'; | ||
this.admin = new Contact(data.admin); | ||
this.domainName = data.domainName || 'Unknown'; | ||
this.creationDate = data.creationDate || 'Unknown'; | ||
this.tech = new Contact(data.tech); | ||
this.updatedDate = data.updatedDate || 'Unknown'; | ||
this.registrant = new Contact(data.registrant); | ||
this.status = data.status || []; | ||
} | ||
get JSON() { | ||
return { | ||
expirationDate: this.expirationDate, | ||
billing: this.billing.JSON, | ||
registrar: this.registrar, | ||
admin: this.admin.JSON, | ||
domainName: this.domainName, | ||
creationDate: this.creationDate, | ||
tech: this.tech.JSON, | ||
updatedDate: this.updatedDate, | ||
registrant: this.registrant.JSON, | ||
status: this.status, | ||
}; | ||
} | ||
get XML() { | ||
return xml(this.XMLData); | ||
} | ||
get XMLData() { | ||
return [ | ||
{ expirationDate: this.expirationDate }, | ||
{ billing: this.billing.XML }, | ||
{ registrar: this.registrar }, | ||
{ admin: this.admin.XML }, | ||
{ domainName: this.domainName }, | ||
{ creationDate: this.creationDate }, | ||
{ tech: this.tech.XML }, | ||
{ updatedDate: this.updatedDate }, | ||
{ registrant: this.registrant.XML }, | ||
{ status: this.status }, | ||
]; | ||
} | ||
get YAML() { | ||
return yaml.stringify(this.JSON); | ||
} | ||
} | ||
|
||
class Full { | ||
constructor(data) { | ||
this.WHOIS = new WHOIS(data.whois); | ||
this.DNS = new DNS(data.dns); | ||
} | ||
get JSON() { | ||
return { | ||
whois: this.WHOIS.JSON, | ||
dns: this.DNS.JSON, | ||
}; | ||
} | ||
get XML() { | ||
return xml({ | ||
full: [ | ||
{ whois: this.WHOIS.XMLData }, | ||
{ dns: this.DNS.XMLData }, | ||
], | ||
}); | ||
} | ||
get YAML() { } | ||
} | ||
|
||
class Crypto { | ||
static DNS = DNS; | ||
static WHOIS = WHOIS; | ||
static Full = Full; | ||
} | ||
|
||
module.exports = Crypto; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.