implemented .createRecord
This commit is contained in:
parent
f4d4bc238b
commit
0ed9c7f4f4
7
dist/cflare.classes.cflareaccount.d.ts
vendored
7
dist/cflare.classes.cflareaccount.d.ts
vendored
@ -1,3 +1,4 @@
|
|||||||
|
import "typings-global";
|
||||||
export declare class CflareAccount {
|
export declare class CflareAccount {
|
||||||
private authEmail;
|
private authEmail;
|
||||||
private authKey;
|
private authKey;
|
||||||
@ -9,10 +10,10 @@ export declare class CflareAccount {
|
|||||||
}): void;
|
}): void;
|
||||||
getZoneId(domainName: string): any;
|
getZoneId(domainName: string): any;
|
||||||
getRecord(domainNameArg: string, typeArg: string): any;
|
getRecord(domainNameArg: string, typeArg: string): any;
|
||||||
createRecord(): any;
|
createRecord(domainNameArg: string, typeArg: string, contentArg: string): any;
|
||||||
removeRecord(): any;
|
removeRecord(): any;
|
||||||
updateRecord(domainNameArg: string, typeArg: string, valueArg: any): any;
|
updateRecord(domainNameArg: string, typeArg: string, valueArg: any): any;
|
||||||
listRecords(domainName: string): any;
|
listRecords(domainNameArg: string): any;
|
||||||
listZones(domainName?: string): any;
|
listZones(domainName?: string): any;
|
||||||
request(methodArg: string, routeArg: string, jsonArg?: any): any;
|
request(methodArg: string, routeArg: string, dataArg?: {}): any;
|
||||||
}
|
}
|
||||||
|
29
dist/cflare.classes.cflareaccount.js
vendored
29
dist/cflare.classes.cflareaccount.js
vendored
File diff suppressed because one or more lines are too long
1
dist/cflare.classes.helpers.d.ts
vendored
1
dist/cflare.classes.helpers.d.ts
vendored
@ -0,0 +1 @@
|
|||||||
|
import "typings-global";
|
3
dist/cflare.classes.helpers.js
vendored
3
dist/cflare.classes.helpers.js
vendored
@ -1,3 +1,4 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJjZmxhcmUuY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlc0NvbnRlbnQiOltdfQ==
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNmbGFyZS5jbGFzc2VzLmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQSIsImZpbGUiOiJjZmxhcmUuY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcclxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9jZmxhcmUucGx1Z2luc1wiKTsiXX0=
|
||||||
|
1
dist/cflare.plugins.d.ts
vendored
1
dist/cflare.plugins.d.ts
vendored
@ -1,3 +1,4 @@
|
|||||||
|
import "typings-global";
|
||||||
export declare let beautylog: any;
|
export declare let beautylog: any;
|
||||||
export declare let q: any;
|
export declare let q: any;
|
||||||
export declare let request: any;
|
export declare let request: any;
|
||||||
|
4
dist/cflare.plugins.js
vendored
4
dist/cflare.plugins.js
vendored
@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/// <reference path="./typings/main.d.ts" />
|
require("typings-global");
|
||||||
exports.beautylog = require("beautylog");
|
exports.beautylog = require("beautylog");
|
||||||
exports.q = require("q");
|
exports.q = require("q");
|
||||||
exports.request = require("request");
|
exports.request = require("request");
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNmbGFyZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDakMsaUJBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUM7QUFDakMsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQU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||||||
export { CflareAccount } from "./cflare.classes.cflareaccount";
|
export { CflareAccount } from "./cflare.classes.cflareaccount";
|
||||||
|
4
dist/index.js
vendored
4
dist/index.js
vendored
@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/// <reference path="./typings/main.d.ts" />
|
require("typings-global");
|
||||||
var cflare_classes_cflareaccount_1 = require("./cflare.classes.cflareaccount");
|
var cflare_classes_cflareaccount_1 = require("./cflare.classes.cflareaccount");
|
||||||
exports.CflareAccount = cflare_classes_cflareaccount_1.CflareAccount;
|
exports.CflareAccount = cflare_classes_cflareaccount_1.CflareAccount;
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDNUMsNkNBQTRCLGdDQUFnQyxDQUFDO0FBQXJELHFFQUFxRCIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cclxuZXhwb3J0IHtDZmxhcmVBY2NvdW50fSBmcm9tIFwiLi9jZmxhcmUuY2xhc3Nlcy5jZmxhcmVhY2NvdW50XCI7Il19
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsNkNBQTRCLGdDQUFnQyxDQUFDO0FBQXJELHFFQUFxRCIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCI7XHJcbmV4cG9ydCB7Q2ZsYXJlQWNjb3VudH0gZnJvbSBcIi4vY2ZsYXJlLmNsYXNzZXMuY2ZsYXJlYWNjb3VudFwiOyJdfQ==
|
||||||
|
10
package.json
10
package.json
@ -21,12 +21,14 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/cflare#readme",
|
"homepage": "https://github.com/pushrocks/cflare#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^5.0.0",
|
"beautylog": "^5.0.6",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"request": "^2.72.0"
|
"request": "^2.72.0",
|
||||||
|
"typings-global": "^1.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts": "^5.1.5",
|
"npmts": "^5.1.13",
|
||||||
"should": "^8.3.1"
|
"should": "^8.4.0",
|
||||||
|
"typings-test": "^1.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -0,0 +1 @@
|
|||||||
|
import "typings-test";
|
18
test/test.js
18
test/test.js
File diff suppressed because one or more lines are too long
25
test/test.ts
25
test/test.ts
@ -1,4 +1,4 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
import "typings-test";
|
||||||
import cflare = require("../dist/index");
|
import cflare = require("../dist/index");
|
||||||
let should = require("should");
|
let should = require("should");
|
||||||
let nogit = require("../nogit/nogit.json");
|
let nogit = require("../nogit/nogit.json");
|
||||||
@ -23,7 +23,7 @@ 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(5000)
|
this.timeout(10000)
|
||||||
testCflareAccount.getZoneId("push.rocks")
|
testCflareAccount.getZoneId("push.rocks")
|
||||||
.then((responseArg)=>{
|
.then((responseArg)=>{
|
||||||
console.log(responseArg);
|
console.log(responseArg);
|
||||||
@ -33,7 +33,7 @@ describe("cflare",function(){
|
|||||||
});
|
});
|
||||||
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(5000);
|
this.timeout(10000);
|
||||||
testCflareAccount.listRecords("push.rocks")
|
testCflareAccount.listRecords("push.rocks")
|
||||||
.then((responseArg) => {
|
.then((responseArg) => {
|
||||||
console.log(responseArg);
|
console.log(responseArg);
|
||||||
@ -41,5 +41,24 @@ describe("cflare",function(){
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
describe(".createRecord",function(){
|
||||||
|
this.timeout(10000);
|
||||||
|
it("should create a valid record for a domain",function(done){
|
||||||
|
testCflareAccount.createRecord("bleu.de","A","127.0.0.1")
|
||||||
|
.then(function(responseArg){
|
||||||
|
console.log(responseArg);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe(".removeRecord",function(){
|
||||||
|
it("should remove a record from Cloudflare",function(done){
|
||||||
|
testCflareAccount.removeRecord()
|
||||||
|
.then(function(responseArg){
|
||||||
|
console.log(responseArg);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
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");
|
||||||
|
|
||||||
@ -41,21 +41,34 @@ export class CflareAccount {
|
|||||||
})
|
})
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
createRecord(){
|
createRecord(domainNameArg:string,typeArg:string,contentArg:string){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
|
this.getZoneId(domainNameArg)
|
||||||
|
.then((domainIdArg)=>{
|
||||||
|
let dataObject = {
|
||||||
|
name: domainNameArg,
|
||||||
|
type: typeArg,
|
||||||
|
content: contentArg
|
||||||
|
};
|
||||||
|
this.request("POST","/zones/" + domainIdArg + "/dns_records",dataObject)
|
||||||
|
.then(function(responseArg){
|
||||||
|
done.resolve(responseArg);
|
||||||
|
});
|
||||||
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
removeRecord(){
|
removeRecord(domainNameArg:string,typeArg:string){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
|
|
||||||
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();
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
listRecords(domainName:string){
|
listRecords(domainNameArg:string){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
this.getZoneId(domainName)
|
this.getZoneId(domainNameArg)
|
||||||
.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){
|
.then(function(responseArg){
|
||||||
@ -76,8 +89,9 @@ export class CflareAccount {
|
|||||||
});
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
request(methodArg:string,routeArg:string,jsonArg?){
|
request(methodArg:string,routeArg:string,dataArg = {}){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
|
let jsonArg:string = JSON.stringify(dataArg);
|
||||||
let options = {
|
let options = {
|
||||||
method:methodArg,
|
method:methodArg,
|
||||||
url:"https://api.cloudflare.com/client/v4" + routeArg,
|
url:"https://api.cloudflare.com/client/v4" + routeArg,
|
||||||
@ -86,7 +100,7 @@ export class CflareAccount {
|
|||||||
"X-Auth-Email":this.authEmail,
|
"X-Auth-Email":this.authEmail,
|
||||||
"X-Auth-Key":this.authKey
|
"X-Auth-Key":this.authKey
|
||||||
},
|
},
|
||||||
json:jsonArg
|
body:jsonArg
|
||||||
};
|
};
|
||||||
plugins.request(options,function(err, res, body){
|
plugins.request(options,function(err, res, body){
|
||||||
if (!err && res.statusCode == 200) {
|
if (!err && res.statusCode == 200) {
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
import "typings-global";
|
||||||
import plugins = require("./cflare.plugins");
|
import plugins = require("./cflare.plugins");
|
@ -1,4 +1,4 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
import "typings-global";
|
||||||
export let beautylog = require("beautylog");
|
export let beautylog = require("beautylog");
|
||||||
export let q = require("q");
|
export let q = require("q");
|
||||||
export let request = require("request");
|
export let request = require("request");
|
@ -1,2 +1,2 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
import "typings-global";
|
||||||
export {CflareAccount} from "./cflare.classes.cflareaccount";
|
export {CflareAccount} from "./cflare.classes.cflareaccount";
|
Loading…
Reference in New Issue
Block a user