now using smartrequest
This commit is contained in:
parent
9699e4bf76
commit
55b305ca1c
4
dist/cflare.classes.cflareaccount.d.ts
vendored
4
dist/cflare.classes.cflareaccount.d.ts
vendored
@ -1,9 +1,8 @@
|
|||||||
import "typings-global";
|
import 'typings-global';
|
||||||
import * as interfaces from './cflare.interfaces';
|
import * as interfaces from './cflare.interfaces';
|
||||||
export declare class CflareAccount {
|
export declare class CflareAccount {
|
||||||
private authEmail;
|
private authEmail;
|
||||||
private authKey;
|
private authKey;
|
||||||
private authCheck();
|
|
||||||
constructor();
|
constructor();
|
||||||
auth(optionsArg: {
|
auth(optionsArg: {
|
||||||
email: string;
|
email: string;
|
||||||
@ -17,4 +16,5 @@ export declare class CflareAccount {
|
|||||||
listRecords(domainNameArg: string): Promise<interfaces.ICflareRecord[]>;
|
listRecords(domainNameArg: string): Promise<interfaces.ICflareRecord[]>;
|
||||||
listZones(domainName?: string): Promise<interfaces.ICflareZone[]>;
|
listZones(domainName?: string): Promise<interfaces.ICflareZone[]>;
|
||||||
request(methodArg: string, routeArg: string, dataArg?: {}): Promise<{}>;
|
request(methodArg: string, routeArg: string, dataArg?: {}): Promise<{}>;
|
||||||
|
private authCheck();
|
||||||
}
|
}
|
||||||
|
88
dist/cflare.classes.cflareaccount.js
vendored
88
dist/cflare.classes.cflareaccount.js
vendored
File diff suppressed because one or more lines are too long
2
dist/cflare.plugins.d.ts
vendored
2
dist/cflare.plugins.d.ts
vendored
@ -1,6 +1,6 @@
|
|||||||
import "typings-global";
|
import "typings-global";
|
||||||
export declare let beautylog: any;
|
export declare let beautylog: any;
|
||||||
export import q = require("smartq");
|
export import q = require("smartq");
|
||||||
export declare let request: any;
|
export import smartrequest = require("smartrequest");
|
||||||
export import smartstring = require("smartstring");
|
export import smartstring = require("smartstring");
|
||||||
export import smartdelay = require('smartdelay');
|
export import smartdelay = require('smartdelay');
|
||||||
|
4
dist/cflare.plugins.js
vendored
4
dist/cflare.plugins.js
vendored
@ -2,7 +2,7 @@
|
|||||||
require("typings-global");
|
require("typings-global");
|
||||||
exports.beautylog = require("beautylog");
|
exports.beautylog = require("beautylog");
|
||||||
exports.q = require("smartq");
|
exports.q = require("smartq");
|
||||||
exports.request = require("request");
|
exports.smartrequest = require("smartrequest");
|
||||||
exports.smartstring = require("smartstring");
|
exports.smartstring = require("smartstring");
|
||||||
exports.smartdelay = require("smartdelay");
|
exports.smartdelay = require("smartdelay");
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2ZsYXJlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9jZmxhcmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXdCO0FBQ2IsUUFBQSxTQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQzVDLDhCQUFvQztBQUN6QixRQUFBLE9BQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7QUFDeEMsNkNBQW1EO0FBQ25ELDJDQUFpRCJ9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2ZsYXJlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9jZmxhcmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXdCO0FBQ2IsUUFBQSxTQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQzVDLDhCQUFvQztBQUNwQywrQ0FBcUQ7QUFDckQsNkNBQW1EO0FBQ25ELDJDQUFpRCJ9
|
@ -23,16 +23,16 @@
|
|||||||
"homepage": "https://github.com/pushrocks/cflare#readme",
|
"homepage": "https://github.com/pushrocks/cflare#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^6.1.1",
|
"beautylog": "^6.1.1",
|
||||||
"request": "^2.79.0",
|
|
||||||
"smartdelay": "^1.0.1",
|
"smartdelay": "^1.0.1",
|
||||||
"smartq": "^1.0.4",
|
"smartq": "^1.1.0",
|
||||||
|
"smartrequest": "^1.0.4",
|
||||||
"smartstring": "^2.0.22",
|
"smartstring": "^2.0.22",
|
||||||
"typings-global": "^1.0.14"
|
"typings-global": "^1.0.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^6.0.0",
|
"npmts-g": "^6.0.0",
|
||||||
"qenv": "^1.1.3",
|
"qenv": "^1.1.3",
|
||||||
"should": "^11.1.2",
|
"smartchai": "^1.0.1",
|
||||||
"typings-test": "^1.0.3"
|
"typings-test": "^1.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/test.d.ts
vendored
2
test/test.d.ts
vendored
@ -1 +1 @@
|
|||||||
import "typings-test";
|
import 'typings-test';
|
||||||
|
51
test/test.js
51
test/test.js
@ -1,19 +1,18 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-test");
|
require("typings-test");
|
||||||
const cflare = require("../dist/index");
|
const cflare = require("../dist/index");
|
||||||
let should = require("should");
|
|
||||||
const qenv_1 = require("qenv");
|
const qenv_1 = require("qenv");
|
||||||
let testQenv = new qenv_1.Qenv(process.cwd(), process.cwd() + "/.nogit");
|
let testQenv = new qenv_1.Qenv(process.cwd(), process.cwd() + '/.nogit');
|
||||||
console.log(testQenv.missingEnvVars);
|
console.log(testQenv.missingEnvVars);
|
||||||
let testCflareAccount = new cflare.CflareAccount();
|
let testCflareAccount = new cflare.CflareAccount();
|
||||||
testCflareAccount.auth({
|
testCflareAccount.auth({
|
||||||
email: process.env.CF_EMAIL,
|
email: process.env.CF_EMAIL,
|
||||||
key: process.env.CF_KEY
|
key: process.env.CF_KEY
|
||||||
});
|
});
|
||||||
describe("cflare", function () {
|
describe('cflare', function () {
|
||||||
describe(".CflareAccount", function () {
|
describe('.CflareAccount', function () {
|
||||||
describe(".listZones()", function () {
|
describe('.listZones()', function () {
|
||||||
it("should display an entire account", function (done) {
|
it('should display an entire account', function (done) {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
testCflareAccount.listZones()
|
testCflareAccount.listZones()
|
||||||
.then((responseArg) => {
|
.then((responseArg) => {
|
||||||
@ -21,63 +20,63 @@ describe("cflare", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe(".getZoneId(domainName)", function () {
|
describe('.getZoneId(domainName)', function () {
|
||||||
it("should get an Cloudflare Id for a domain string", function (done) {
|
it('should get an Cloudflare Id for a domain string', function (done) {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
testCflareAccount.getZoneId("bleu.de")
|
testCflareAccount.getZoneId('bleu.de')
|
||||||
.then((responseArg) => {
|
.then((responseArg) => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe(".listRecords(domainName)", function () {
|
describe('.listRecords(domainName)', function () {
|
||||||
it("should list all records for a specific Domain Name", function (done) {
|
it('should list all records for a specific Domain Name', function (done) {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
testCflareAccount.listRecords("bleu.de")
|
testCflareAccount.listRecords('bleu.de')
|
||||||
.then((responseArg) => {
|
.then((responseArg) => {
|
||||||
console.log(responseArg);
|
console.log(responseArg);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe(".createRecord", function () {
|
describe('.createRecord', function () {
|
||||||
it("should create a valid record for a level 2 domain", function (done) {
|
it('should create a valid record for a level 2 domain', function (done) {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
testCflareAccount.createRecord("bleu.de", "A", "127.0.0.1")
|
testCflareAccount.createRecord('bleu.de', 'A', '127.0.0.1')
|
||||||
.then(function (responseArg) {
|
.then(function (responseArg) {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should create a valid record for a subdomain", function (done) {
|
it('should create a valid record for a subdomain', function (done) {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
testCflareAccount.createRecord("subdomain.bleu.de", "A", "127.0.0.1")
|
testCflareAccount.createRecord('subdomain.bleu.de', 'A', '127.0.0.1')
|
||||||
.then(function (responseArg) {
|
.then(function (responseArg) {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe(".getRecord", function () {
|
describe('.getRecord', function () {
|
||||||
it("should get a record from Cloudflare", function (done) {
|
it('should get a record from Cloudflare', function (done) {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
testCflareAccount.getRecord("bleu.de", "A")
|
testCflareAccount.getRecord('bleu.de', 'A')
|
||||||
.then(function (responseArg) {
|
.then(function (responseArg) {
|
||||||
console.log(responseArg);
|
console.log(responseArg);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe(".removeRecord", function () {
|
describe('.removeRecord', function () {
|
||||||
it("should remove a record from Cloudflare", function (done) {
|
it('should remove a record from Cloudflare', function (done) {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
testCflareAccount.removeRecord("bleu.de", "A")
|
testCflareAccount.removeRecord('bleu.de', 'A')
|
||||||
.then(function (responseArg) {
|
.then(function (responseArg) {
|
||||||
console.log(responseArg);
|
console.log(responseArg);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should remove a subdomain record from Cloudflare", function (done) {
|
it('should remove a subdomain record from Cloudflare', function (done) {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
testCflareAccount.removeRecord("subdomain.bleu.de", "A")
|
testCflareAccount.removeRecord('subdomain.bleu.de', 'A')
|
||||||
.then(function (responseArg) {
|
.then(function (responseArg) {
|
||||||
console.log(responseArg);
|
console.log(responseArg);
|
||||||
done();
|
done();
|
||||||
@ -86,4 +85,4 @@ describe("cflare", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFzQjtBQUN0Qix3Q0FBeUM7QUFDekMsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDO0FBQy9CLCtCQUEwQjtBQUMxQixJQUFJLFFBQVEsR0FBRyxJQUFJLFdBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLEVBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxHQUFHLFNBQVMsQ0FBQyxDQUFDO0FBQ2pFLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxDQUFDLGNBQWMsQ0FBQyxDQUFDO0FBQ3JDLElBQUksaUJBQWlCLEdBQUcsSUFBSSxNQUFNLENBQUMsYUFBYSxFQUFFLENBQUM7QUFDbkQsaUJBQWlCLENBQUMsSUFBSSxDQUFDO0lBQ25CLEtBQUssRUFBRSxPQUFPLENBQUMsR0FBRyxDQUFDLFFBQVE7SUFDM0IsR0FBRyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTTtDQUMxQixDQUFDLENBQUM7QUFFSCxRQUFRLENBQUMsUUFBUSxFQUFDO0lBQ2QsUUFBUSxDQUFDLGdCQUFnQixFQUFDO1FBQ3RCLFFBQVEsQ0FBQyxjQUFjLEVBQUM7WUFDcEIsRUFBRSxDQUFDLGtDQUFrQyxFQUFDLFVBQVMsSUFBSTtnQkFDL0MsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQztnQkFDcEIsaUJBQWlCLENBQUMsU0FBUyxFQUFF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U8sQ0FBQyxHQUFHLENBQUMsV0FBVyxDQUFDLENBQUE7b0JBQ3hCLElBQUksRUFBRSxDQUFBO2dCQUNWLENBQUMsQ0FBQyxDQUFBO1lBQ1YsQ0FBQyxDQUFDLENBQUE7UUFDTixDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
160
test/test.ts
160
test/test.ts
@ -1,88 +1,88 @@
|
|||||||
import "typings-test";
|
import 'typings-test'
|
||||||
import cflare = require("../dist/index");
|
import cflare = require('../dist/index')
|
||||||
let should = require("should");
|
import { expect } from 'smartchai'
|
||||||
import {Qenv} from "qenv";
|
import { Qenv } from 'qenv'
|
||||||
let testQenv = new Qenv(process.cwd(),process.cwd() + "/.nogit");
|
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit')
|
||||||
console.log(testQenv.missingEnvVars);
|
console.log(testQenv.missingEnvVars)
|
||||||
let testCflareAccount = new cflare.CflareAccount();
|
let testCflareAccount = new cflare.CflareAccount()
|
||||||
testCflareAccount.auth({
|
testCflareAccount.auth({
|
||||||
email: process.env.CF_EMAIL,
|
email: process.env.CF_EMAIL,
|
||||||
key: process.env.CF_KEY
|
key: process.env.CF_KEY
|
||||||
});
|
})
|
||||||
|
|
||||||
describe("cflare",function(){
|
describe('cflare', function () {
|
||||||
describe(".CflareAccount",function(){
|
describe('.CflareAccount', function () {
|
||||||
describe(".listZones()",function(){
|
describe('.listZones()', function () {
|
||||||
it("should display an entire account",function(done){
|
it('should display an entire account', function (done) {
|
||||||
this.timeout(30000);
|
|
||||||
testCflareAccount.listZones()
|
|
||||||
.then((responseArg)=>{
|
|
||||||
done();
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".getZoneId(domainName)",function(){
|
|
||||||
it("should get an Cloudflare Id for a domain string",function(done){
|
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
testCflareAccount.getZoneId("bleu.de")
|
testCflareAccount.listZones()
|
||||||
.then((responseArg)=>{
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".listRecords(domainName)",function(){
|
|
||||||
it("should list all records for a specific Domain Name",function(done){
|
|
||||||
this.timeout(30000);
|
|
||||||
testCflareAccount.listRecords("bleu.de")
|
|
||||||
.then((responseArg) => {
|
.then((responseArg) => {
|
||||||
console.log(responseArg);
|
done()
|
||||||
done();
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
describe('.getZoneId(domainName)', function () {
|
||||||
|
it('should get an Cloudflare Id for a domain string', function (done) {
|
||||||
|
this.timeout(30000)
|
||||||
|
testCflareAccount.getZoneId('bleu.de')
|
||||||
|
.then((responseArg) => {
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('.listRecords(domainName)', function () {
|
||||||
|
it('should list all records for a specific Domain Name', function (done) {
|
||||||
|
this.timeout(30000)
|
||||||
|
testCflareAccount.listRecords('bleu.de')
|
||||||
|
.then((responseArg) => {
|
||||||
|
console.log(responseArg)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('.createRecord', function () {
|
||||||
|
it('should create a valid record for a level 2 domain', function (done) {
|
||||||
|
this.timeout(30000)
|
||||||
|
testCflareAccount.createRecord('bleu.de', 'A', '127.0.0.1')
|
||||||
|
.then(function (responseArg) {
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('should create a valid record for a subdomain', function (done) {
|
||||||
|
this.timeout(30000)
|
||||||
|
testCflareAccount.createRecord('subdomain.bleu.de', 'A', '127.0.0.1')
|
||||||
|
.then(function (responseArg) {
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('.getRecord', function () {
|
||||||
|
it('should get a record from Cloudflare', function (done) {
|
||||||
|
this.timeout(30000)
|
||||||
|
testCflareAccount.getRecord('bleu.de', 'A')
|
||||||
|
.then(function (responseArg) {
|
||||||
|
console.log(responseArg)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('.removeRecord', function () {
|
||||||
|
it('should remove a record from Cloudflare', function (done) {
|
||||||
|
this.timeout(30000)
|
||||||
|
testCflareAccount.removeRecord('bleu.de', 'A')
|
||||||
|
.then(function (responseArg) {
|
||||||
|
console.log(responseArg)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('should remove a subdomain record from Cloudflare', function (done) {
|
||||||
|
this.timeout(30000)
|
||||||
|
testCflareAccount.removeRecord('subdomain.bleu.de', 'A')
|
||||||
|
.then(function (responseArg) {
|
||||||
|
console.log(responseArg)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
describe(".createRecord",function(){
|
|
||||||
it("should create a valid record for a level 2 domain",function(done){
|
|
||||||
this.timeout(30000);
|
|
||||||
testCflareAccount.createRecord("bleu.de","A","127.0.0.1")
|
|
||||||
.then(function(responseArg){
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should create a valid record for a subdomain",function(done){
|
|
||||||
this.timeout(30000);
|
|
||||||
testCflareAccount.createRecord("subdomain.bleu.de","A","127.0.0.1")
|
|
||||||
.then(function(responseArg){
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".getRecord",function(){
|
|
||||||
it("should get a record from Cloudflare",function(done){
|
|
||||||
this.timeout(30000);
|
|
||||||
testCflareAccount.getRecord("bleu.de","A")
|
|
||||||
.then(function(responseArg){
|
|
||||||
console.log(responseArg);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".removeRecord",function(){
|
|
||||||
it("should remove a record from Cloudflare",function(done){
|
|
||||||
this.timeout(30000);
|
|
||||||
testCflareAccount.removeRecord("bleu.de","A")
|
|
||||||
.then(function(responseArg){
|
|
||||||
console.log(responseArg);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should remove a subdomain record from Cloudflare",function(done){
|
|
||||||
this.timeout(30000);
|
|
||||||
testCflareAccount.removeRecord("subdomain.bleu.de","A")
|
|
||||||
.then(function(responseArg){
|
|
||||||
console.log(responseArg);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
|
@ -1,167 +1,161 @@
|
|||||||
import "typings-global";
|
import 'typings-global';
|
||||||
import plugins = require("./cflare.plugins");
|
import plugins = require('./cflare.plugins')
|
||||||
import helpers = require("./cflare.classes.helpers");
|
import helpers = require('./cflare.classes.helpers')
|
||||||
import * as interfaces from './cflare.interfaces'
|
import * as interfaces from './cflare.interfaces'
|
||||||
|
|
||||||
export class CflareAccount {
|
export class CflareAccount {
|
||||||
private authEmail: string;
|
private authEmail: string
|
||||||
private authKey: string;
|
private authKey: string
|
||||||
private authCheck() {
|
|
||||||
return (this.authEmail && this.authKey); //check if auth is available
|
|
||||||
}
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
};
|
|
||||||
auth(optionsArg: { email: string, key: string }) {
|
|
||||||
this.authEmail = optionsArg.email;
|
|
||||||
this.authKey = optionsArg.key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auth(optionsArg: { email: string, key: string }) {
|
||||||
|
this.authEmail = optionsArg.email
|
||||||
|
this.authKey = optionsArg.key
|
||||||
|
}
|
||||||
|
|
||||||
getZoneId(domainName: string) {
|
getZoneId(domainName: string) {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer()
|
||||||
this.listZones(domainName)
|
this.listZones(domainName)
|
||||||
.then(zoneArrayArg => {
|
.then(zoneArrayArg => {
|
||||||
let filteredResponse = zoneArrayArg.filter((zoneArg) => {
|
let filteredResponse = zoneArrayArg.filter((zoneArg) => {
|
||||||
return zoneArg.name === domainName;
|
return zoneArg.name === domainName
|
||||||
});
|
})
|
||||||
if (filteredResponse.length >= 1) {
|
if (filteredResponse.length >= 1) {
|
||||||
done.resolve(filteredResponse[0].id);
|
done.resolve(filteredResponse[ 0 ].id)
|
||||||
} else {
|
} else {
|
||||||
plugins.beautylog.error(`the domain ${domainName} does not appear to be in this account!`);
|
plugins.beautylog.error(`the domain ${domainName} does not appear to be in this account!`)
|
||||||
done.reject(undefined);
|
done.reject(undefined)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
return done.promise;
|
return done.promise
|
||||||
}
|
}
|
||||||
getRecord(domainNameArg: string, typeArg: string): Promise<interfaces.ICflareRecord> {
|
getRecord(domainNameArg: string, typeArg: string): Promise<interfaces.ICflareRecord> {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer()
|
||||||
let result: interfaces.ICflareRecord
|
let result: interfaces.ICflareRecord
|
||||||
|
|
||||||
let domain = new plugins.smartstring.Domain(domainNameArg);
|
let domain = new plugins.smartstring.Domain(domainNameArg)
|
||||||
this.listRecords(domain.zoneName)
|
this.listRecords(domain.zoneName)
|
||||||
.then((recordArrayArg) => {
|
.then((recordArrayArg) => {
|
||||||
let filteredResponse = recordArrayArg.filter((recordArg) => {
|
let filteredResponse = recordArrayArg.filter((recordArg) => {
|
||||||
return (recordArg.type == typeArg && recordArg.name == domainNameArg);
|
return (recordArg.type === typeArg && recordArg.name === domainNameArg)
|
||||||
})
|
})
|
||||||
done.resolve(filteredResponse[0]);
|
done.resolve(filteredResponse[ 0 ])
|
||||||
})
|
})
|
||||||
return done.promise;
|
return done.promise
|
||||||
};
|
};
|
||||||
createRecord(domainNameArg: string, typeArg: string, contentArg: string) {
|
createRecord(domainNameArg: string, typeArg: string, contentArg: string) {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer()
|
||||||
let domain = new plugins.smartstring.Domain(domainNameArg);
|
let domain = new plugins.smartstring.Domain(domainNameArg)
|
||||||
this.getZoneId(domain.zoneName)
|
this.getZoneId(domain.zoneName)
|
||||||
.then((domainIdArg) => {
|
.then((domainIdArg) => {
|
||||||
let dataObject = {
|
let dataObject = {
|
||||||
name: domain.fullName,
|
name: domain.fullName,
|
||||||
type: typeArg,
|
type: typeArg,
|
||||||
content: contentArg
|
content: contentArg
|
||||||
};
|
}
|
||||||
this.request("POST", "/zones/" + domainIdArg + "/dns_records", dataObject)
|
this.request('POST', '/zones/' + domainIdArg + '/dns_records', dataObject)
|
||||||
.then(function (responseArg) {
|
.then(function (responseArg) {
|
||||||
done.resolve(responseArg);
|
done.resolve(responseArg)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
return done.promise;
|
return done.promise
|
||||||
};
|
};
|
||||||
removeRecord(domainNameArg: string, typeArg: string) {
|
removeRecord(domainNameArg: string, typeArg: string) {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer()
|
||||||
let domain = new plugins.smartstring.Domain(domainNameArg);
|
let domain = new plugins.smartstring.Domain(domainNameArg)
|
||||||
this.getRecord(domain.fullName, typeArg)
|
this.getRecord(domain.fullName, typeArg)
|
||||||
.then((responseArg) => {
|
.then((responseArg) => {
|
||||||
if (responseArg) {
|
if (responseArg) {
|
||||||
let requestRoute: string = "/zones/" + responseArg.zone_id + "/dns_records/" + responseArg.id;
|
let requestRoute: string = '/zones/' + responseArg.zone_id + '/dns_records/' + responseArg.id
|
||||||
this.request("DELETE", requestRoute)
|
this.request('DELETE', requestRoute)
|
||||||
.then((responseArg) => {
|
.then((responseArg) => {
|
||||||
done.resolve(responseArg);
|
done.resolve(responseArg)
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
done.reject();
|
done.reject()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
return done.promise;
|
return done.promise
|
||||||
};
|
};
|
||||||
updateRecord(domainNameArg: string, typeArg: string, valueArg) {
|
updateRecord(domainNameArg: string, typeArg: string, valueArg) {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer()
|
||||||
let domain = new plugins.smartstring.Domain(domainNameArg);
|
let domain = new plugins.smartstring.Domain(domainNameArg)
|
||||||
return done.promise;
|
return done.promise
|
||||||
};
|
};
|
||||||
listRecords(domainNameArg: string): Promise<interfaces.ICflareRecord[]> {
|
listRecords(domainNameArg: string): Promise<interfaces.ICflareRecord[]> {
|
||||||
let done = plugins.q.defer<interfaces.ICflareRecord[]>();
|
let done = plugins.q.defer<interfaces.ICflareRecord[]>()
|
||||||
let result: interfaces.ICflareRecord[] = []
|
let result: interfaces.ICflareRecord[] = []
|
||||||
|
|
||||||
let domain = new plugins.smartstring.Domain(domainNameArg);
|
let domain = new plugins.smartstring.Domain(domainNameArg)
|
||||||
this.getZoneId(domain.zoneName)
|
this.getZoneId(domain.zoneName)
|
||||||
.then((domainIdArg) => {
|
.then((domainIdArg) => {
|
||||||
this.request("GET", "/zones/" + domainIdArg + "/dns_records?per_page=100")
|
this.request('GET', '/zones/' + domainIdArg + '/dns_records?per_page=100')
|
||||||
.then(function (responseArg: any) {
|
.then(function (responseArg: any) {
|
||||||
result = responseArg.result
|
result = responseArg.result
|
||||||
done.resolve(result);
|
done.resolve(result)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
return done.promise;
|
return done.promise
|
||||||
}
|
}
|
||||||
listZones(domainName?: string): Promise<interfaces.ICflareZone[]> { // TODO: handle pagination
|
listZones(domainName?: string): Promise<interfaces.ICflareZone[]> { // TODO: handle pagination
|
||||||
let done = plugins.q.defer<interfaces.ICflareZone[]>();
|
let done = plugins.q.defer<interfaces.ICflareZone[]>()
|
||||||
let requestRoute = "/zones?per_page=50"
|
let requestRoute = '/zones?per_page=50'
|
||||||
if (domainName) requestRoute = requestRoute + "&name=" + domainName;
|
if (domainName) requestRoute = requestRoute + '&name=' + domainName
|
||||||
let result = [];
|
let result = []
|
||||||
this.request("GET", requestRoute)
|
this.request('GET', requestRoute)
|
||||||
.then((responseArg: any) => {
|
.then((responseArg: any) => {
|
||||||
result = responseArg.result;
|
result = responseArg.result
|
||||||
done.resolve(result);
|
done.resolve(result)
|
||||||
});
|
})
|
||||||
return done.promise;
|
return done.promise
|
||||||
};
|
};
|
||||||
request(methodArg: string, routeArg: string, dataArg = {}) {
|
request(methodArg: string, routeArg: string, dataArg = {}) {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer()
|
||||||
let jsonArg: string = JSON.stringify(dataArg);
|
let jsonArg: string = JSON.stringify(dataArg)
|
||||||
let options = {
|
let options: plugins.smartrequest.ISmartRequestOptions = {
|
||||||
method: methodArg,
|
method: methodArg,
|
||||||
url: "https://api.cloudflare.com/client/v4" + routeArg,
|
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
"X-Auth-Email": this.authEmail,
|
'X-Auth-Email': this.authEmail,
|
||||||
"X-Auth-Key": this.authKey
|
'X-Auth-Key': this.authKey
|
||||||
},
|
},
|
||||||
body: jsonArg
|
requestBody: jsonArg
|
||||||
};
|
}
|
||||||
//console.log(options);
|
// console.log(options);
|
||||||
let retryCount = 0
|
let retryCount = 0
|
||||||
|
|
||||||
let makeRequest = () => {
|
let makeRequest = async () => {
|
||||||
plugins.request(options, function (err, res, body) {
|
let response: any = await plugins.smartrequest.request(
|
||||||
let responseObj
|
`https://api.cloudflare.com/client/v4${routeArg}`,
|
||||||
try {
|
options
|
||||||
responseObj = JSON.parse(body);
|
)
|
||||||
} catch (err) {
|
if (response.statusCode === 200) {
|
||||||
console.log(res.statusCode)
|
done.resolve(response.body)
|
||||||
retryRequest()
|
} else if (response.statusCode === 429) {
|
||||||
return
|
console.log('rate limited! Waiting for retry!')
|
||||||
}
|
retryRequest()
|
||||||
if (!err && res.statusCode === 200) {
|
} else {
|
||||||
done.resolve(responseObj);
|
console.log(response.status)
|
||||||
} else if (!err && res.statusCode === 429) {
|
console.log(response.messages)
|
||||||
console.log('rate limited! Waiting for retry!')
|
console.log(response.errors)
|
||||||
retryRequest()
|
done.reject(new Error('request failed'))
|
||||||
return
|
}
|
||||||
} else {
|
|
||||||
console.log(res.statusCode)
|
|
||||||
console.log(responseObj.messages);
|
|
||||||
console.log(responseObj.errors);
|
|
||||||
done.reject(err);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
let retryRequest = async (delayTimeArg = 15000) => {
|
let retryRequest = async (delayTimeArg = 6000) => {
|
||||||
console.log(`retry started and waiting for ${delayTimeArg} ms`)
|
console.log(`retry started and waiting for ${delayTimeArg} ms`)
|
||||||
await plugins.smartdelay.delayFor(delayTimeArg)
|
await plugins.smartdelay.delayFor(delayTimeArg)
|
||||||
if (retryCount < 3) {
|
if (retryCount < 10) {
|
||||||
retryCount++
|
retryCount++
|
||||||
makeRequest()
|
return await makeRequest()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
makeRequest()
|
makeRequest()
|
||||||
return done.promise;
|
return done.promise
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
private authCheck() {
|
||||||
|
return (this.authEmail && this.authKey) // check if auth is available
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import "typings-global";
|
import "typings-global";
|
||||||
export let beautylog = require("beautylog");
|
export let beautylog = require("beautylog");
|
||||||
export import q = require("smartq");
|
export import q = require("smartq");
|
||||||
export let request = require("request");
|
export import smartrequest = require("smartrequest");
|
||||||
export import smartstring = require("smartstring");
|
export import smartstring = require("smartstring");
|
||||||
export import smartdelay = require('smartdelay');
|
export import smartdelay = require('smartdelay');
|
3
tslint.json
Normal file
3
tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "tslint-config-standard"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user