From 0ed9c7f4f4a17ac28061282e917f1a8df33d5e5e Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Tue, 24 May 2016 23:36:06 +0200 Subject: [PATCH] implemented .createRecord --- dist/cflare.classes.cflareaccount.d.ts | 7 ++++--- dist/cflare.classes.cflareaccount.js | 29 +++++++++++++++++++------- dist/cflare.classes.helpers.d.ts | 1 + dist/cflare.classes.helpers.js | 3 ++- dist/cflare.plugins.d.ts | 1 + dist/cflare.plugins.js | 4 ++-- dist/index.d.ts | 1 + dist/index.js | 4 ++-- package.json | 10 +++++---- test/test.d.ts | 1 + test/test.js | 18 ++++++++++++---- test/test.ts | 25 +++++++++++++++++++--- ts/cflare.classes.cflareaccount.ts | 28 ++++++++++++++++++------- ts/cflare.classes.helpers.ts | 2 +- ts/cflare.plugins.ts | 2 +- ts/index.ts | 2 +- 16 files changed, 102 insertions(+), 36 deletions(-) diff --git a/dist/cflare.classes.cflareaccount.d.ts b/dist/cflare.classes.cflareaccount.d.ts index 7412645..86b7993 100644 --- a/dist/cflare.classes.cflareaccount.d.ts +++ b/dist/cflare.classes.cflareaccount.d.ts @@ -1,3 +1,4 @@ +import "typings-global"; export declare class CflareAccount { private authEmail; private authKey; @@ -9,10 +10,10 @@ export declare class CflareAccount { }): void; getZoneId(domainName: string): any; getRecord(domainNameArg: string, typeArg: string): any; - createRecord(): any; + createRecord(domainNameArg: string, typeArg: string, contentArg: string): any; removeRecord(): any; updateRecord(domainNameArg: string, typeArg: string, valueArg: any): any; - listRecords(domainName: string): any; + listRecords(domainNameArg: string): any; listZones(domainName?: string): any; - request(methodArg: string, routeArg: string, jsonArg?: any): any; + request(methodArg: string, routeArg: string, dataArg?: {}): any; } diff --git a/dist/cflare.classes.cflareaccount.js b/dist/cflare.classes.cflareaccount.js index 6ef6152..4fd9bee 100644 --- a/dist/cflare.classes.cflareaccount.js +++ b/dist/cflare.classes.cflareaccount.js @@ -1,5 +1,5 @@ "use strict"; -/// +require("typings-global"); var plugins = require("./cflare.plugins"); var CflareAccount = (function () { function CflareAccount() { @@ -40,8 +40,21 @@ var CflareAccount = (function () { return done.promise; }; ; - CflareAccount.prototype.createRecord = function () { + CflareAccount.prototype.createRecord = function (domainNameArg, typeArg, contentArg) { + var _this = this; var done = plugins.q.defer(); + this.getZoneId(domainNameArg) + .then(function (domainIdArg) { + var dataJson = { + name: domainNameArg, + type: typeArg, + content: contentArg + }; + _this.request("POST", "/zones/" + domainIdArg + "/dns_records", dataJson) + .then(function (responseArg) { + done.resolve(responseArg); + }); + }); return done.promise; }; ; @@ -55,10 +68,10 @@ var CflareAccount = (function () { return done.promise; }; ; - CflareAccount.prototype.listRecords = function (domainName) { + CflareAccount.prototype.listRecords = function (domainNameArg) { var _this = this; var done = plugins.q.defer(); - this.getZoneId(domainName) + this.getZoneId(domainNameArg) .then(function (domainIdArg) { _this.request("GET", "/zones/" + domainIdArg + "/dns_records?per_page=100") .then(function (responseArg) { @@ -81,8 +94,10 @@ var CflareAccount = (function () { return done.promise; }; ; - CflareAccount.prototype.request = function (methodArg, routeArg, jsonArg) { + CflareAccount.prototype.request = function (methodArg, routeArg, dataArg) { + if (dataArg === void 0) { dataArg = {}; } var done = plugins.q.defer(); + var jsonArg = JSON.stringify(dataArg); var options = { method: methodArg, url: "https://api.cloudflare.com/client/v4" + routeArg, @@ -91,7 +106,7 @@ var CflareAccount = (function () { "X-Auth-Email": this.authEmail, "X-Auth-Key": this.authKey }, - json: jsonArg + body: jsonArg }; plugins.request(options, function (err, res, body) { if (!err && res.statusCode == 200) { @@ -112,4 +127,4 @@ var CflareAccount = (function () { exports.CflareAccount = CflareAccount; ; -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNmbGFyZS5jbGFzc2VzLmNmbGFyZWFjY291bnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxrQkFBa0IsQ0F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CA9IG9wdGlvbnNBcmcuZW1haWw7XHJcbiAgICAgICAgdGhpcy5hdXRoS2V5ID0gb3B0aW9uc0FyZy5rZXk7ICAgICAgIFxyXG4gICAgfVxyXG4gICAgZ2V0Wm9uZUlkKGRvbWFpbk5hbWU6c3RyaW5nKXtcclxuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xyXG4gICAgICAgIHRoaXMubGlzdFpvbmVzKGRvbWFpbk5hbWUpXHJcbiAgICAgICAgICAgIC50aGVuKChyZXNwb25zZUFyZykgPT4ge1xyXG4gICAgICAgICAgICAgICAgbGV0IGZpbHRlcmVkUmVzcG9uc2UgPSByZXNwb25zZUFyZy5yZXN1bHQuZmlsdGVyKCh6b25lQXJnKT0+e1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB6b25lQXJnLm5hbWUgPT09IGRvbWFpbk5hbWU7XHJcbiAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgICAgIGlmIChmaWx0ZXJlZFJlc3BvbnNlLmxlbmd0aCA+PSAxKXtcclxuICAgICAgICAgICAgICAgICAgICBkb25lLnJlc29sdmUoZmlsdGVyZWRSZXNwb25zZVswXS5pZCk7XHJcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xyXG4gICAgICAgICAgICAgICAgICAgIHBsdWdpbnMuYmVhdXR5bG9nLmVycm9yKFwidGhlIGRvbWFpbiBcIiArIGRvbWFpbk5hbWUuYmx1ZSArIFwiIGRvZXMgbm90IGFwcGVhciB0byBiZSBpbiB0aGlzIGFjY291bnQhXCIpO1xyXG4gICAgICAgICAgICAgICAgICAgIGRvbmUucmVqZWN0KHVuZGVmaW5lZCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XHJcbiAgICB9XHJcbiAgICBnZXRSZWNvcmQoZG9tYWluTmFtZUFyZzpzdHJpbmcsdHlwZUFyZzpzdHJpbmcpe1xyXG4gICAgICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XHJcbiAgICAgICAgdGhpcy5saXN0UmVjb3Jkcyhkb21haW5OYW1lQXJnKVxyXG4gICAgICAgICAgICAudGhlbigocmVzcG9uc2VBcmcpID0+IHtcclxuICAgICAgICAgICAgICAgIGxldCBmaWx0ZXJlZFJlc3BvbnNlID0gcmVzcG9uc2VBcmcucmVzdWx0LmZpbHRlcigocmVjb3JkQXJnKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChyZWNvcmRBcmcudHlwZSA9PSB0eXBlQXJnICYmIHJlY29yZEFyZy5uYW1lID09IGRvbWFpbk5hbWVBcmcpOyBcclxuICAgICAgICAgICAgICAgIH0pXHJcbiAgICAgICAgICAgIH0pXHJcbiAgICAgICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcclxuICAgIH07XHJcbiAgICBjcmVhdGVSZWNvcmQoKXtcclxuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xyXG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XHJcbiAgICB9O1xyXG4gICAgcmVtb3ZlUmVjb3JkKCl7XHJcbiAgICAgICAgbGV0IGRvbmUgPSBwbHVnaW5zLnEuZGVmZXIoKTtcclxuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xyXG4gICAgfTtcclxuICAgIHVwZGF0ZVJlY29yZChkb21haW5OYW1lQXJnOnN0cmluZyx0eXBlQXJnOnN0cmluZyx2YWx1ZUFyZyl7XHJcbiAgICAgICAgbGV0IGRvbmUgPSBwbHVnaW5zLnEuZGVmZXIoKTtcclxuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xyXG4gICAgfTtcclxuICAgIGxpc3RSZWNvcmRzKGRvbWFpbk5hbWU6c3RyaW5nKXtcclxuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xyXG4gICAgICAgIHRoaXMuZ2V0Wm9uZUlkKGRvbWFpbk5hbWUpXHJcbiAgICAgICAgICAgIC50aGVuKChkb21haW5JZEFyZyk9PntcclxuICAgICAgICAgICAgICAgIHRoaXMucmVxdWVzdChcIkdFVFwiLFwiL3pvbmVzL1wiICsgZG9tYWluSWRBcmcgKyBcIi9kbnNfcmVjb3Jkcz9wZXJfcGFnZT0xMDBcIilcclxuICAgICAgICAgICAgICAgICAgICAudGhlbihmdW5jdGlvbihyZXNwb25zZUFyZyl7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUucmVzb2x2ZShyZXNwb25zZUFyZyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XHJcbiAgICB9XHJcbiAgICBsaXN0Wm9uZXMoZG9tYWluTmFtZT86c3RyaW5nKXsgLy8gVE9ETzogaGFuZGxlIHBhZ2luYXRpb25cclxuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xyXG4gICAgICAgIGxldCByZXF1ZXN0Um91dGUgPSBcIi96b25lcz9wZXJfcGFnZT01MFwiXHJcbiAgICAgICAgaWYoZG9tYWluTmFtZSkgcmVxdWVzdFJvdXRlID0gcmVxdWVzdFJvdXRlICsgXCImbmFtZT1cIiArIGRvbWFpbk5hbWU7XHJcbiAgICAgICAgbGV0IHJlc3VsdCA9IHt9OyBcclxuICAgICAgICB0aGlzLnJlcXVlc3QoXCJHRVRcIixyZXF1ZXN0Um91dGUpXHJcbiAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uKHJlc3BvbnNlQXJnKXtcclxuICAgICAgICAgICAgICAgIHJlc3VsdCA9IHJlc3BvbnNlQXJnO1xyXG4gICAgICAgICAgICAgICAgZG9uZS5yZXNvbHZlKHJlc3VsdCk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XHJcbiAgICB9O1xyXG4gICAgcmVxdWVzdChtZXRob2RBcmc6c3RyaW5nLHJvdXRlQXJnOnN0cmluZyxqc29uQXJnPyl7XHJcbiAgICAgICAgbGV0IGRvbmUgPSBwbHVnaW5zLnEuZGVmZXIoKTtcclxuICAgICAgICBsZXQgb3B0aW9ucyA9IHtcclxuICAgICAgICAgICAgbWV0aG9kOm1ldGhvZEFyZyxcclxuICAgICAgICAgICAgdXJsOlwiaHR0cHM6Ly9hcGkuY2xvdWRmbGFyZS5jb20vY2xpZW50L3Y0XCIgKyByb3V0ZUFyZyxcclxuICAgICAgICAgICAgaGVhZGVyczp7XHJcbiAgICAgICAgICAgICAgICBcIkNvbnRlbnQtVHlwZVwiOlwiYXBwbGljYXRpb24vanNvblwiLFxyXG4gICAgICAgICAgICAgICAgXCJYLUF1dGgtRW1haWxcIjp0aGlzLmF1dGhFbWFpbCxcclxuICAgICAgICAgICAgICAgIFwiWC1BdXRoLUtleVwiOnRoaXMuYXV0aEtleVxyXG4gICAgICAgICAgICB9LFxyXG4gICAgICAgICAgICBqc29uOmpzb25BcmdcclxuICAgICAgICB9O1xyXG4gICAgICAgIHBsdWdpbnMucmVxdWVzdChvcHRpb25zLGZ1bmN0aW9uKGVyciwgcmVzLCBib2R5KXtcclxuICAgICAgICAgICAgaWYgKCFlcnIgJiYgcmVzLnN0YXR1c0NvZGUgPT0gMjAwKSB7XHJcbiAgICAgICAgICAgICAgICB2YXIgcmVzcG9uc2VPYmogPSBKU09OLnBhcnNlKGJvZHkpO1xyXG4gICAgICAgICAgICAgICAgZG9uZS5yZXNvbHZlKHJlc3BvbnNlT2JqKTtcclxuICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGVycik7XHJcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhyZXMpO1xyXG4gICAgICAgICAgICAgICAgZG9uZS5yZWplY3QoZXJyKTtcclxuICAgICAgICAgICAgfTtcclxuICAgICAg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ICAgICB0aGlzLmxpc3Rab25lcyhkb21haW5OYW1lKVxyXG4gICAgICAgICAgICAudGhlbigocmVzcG9uc2VBcmcpID0+IHtcclxuICAgICAgICAgICAgICAgIGxldCBmaWx0ZXJlZFJlc3BvbnNlID0gcmVzcG9uc2VBcmcucmVzdWx0LmZpbHRlcigoem9uZUFyZyk9PntcclxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gem9uZUFyZy5uYW1lID09PSBkb21haW5OYW1lO1xyXG4gICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgICAgICBpZiAoZmlsdGVyZWRSZXNwb25zZS5sZW5ndGggPj0gMSl7XHJcbiAgICAgICAgICAgICAgICAgICAgZG9uZS5yZXNvbHZlKGZpbHRlcmVkUmVzcG9uc2VbMF0uaWQpO1xyXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy5lcnJvcihcInRoZSBkb21haW4gXCIgKyBkb21haW5OYW1lLmJsdWUgKyBcIiBkb2VzIG5vdCBhcHBlYXIgdG8gYmUgaW4gdGhpcyBhY2NvdW50IVwiKTtcclxuICAgICAgICAgICAgICAgICAgICBkb25lLnJlamVjdCh1bmRlZmluZWQpO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xyXG4gICAgfVxyXG4gICAgZ2V0UmVjb3JkKGRvbWFpbk5hbWVBcmc6c3RyaW5nLHR5cGVBcmc6c3RyaW5nKXtcclxuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xyXG4gICAgICAgIHRoaXMubGlzdFJlY29yZHMoZG9tYWluTmFtZUFyZylcclxuICAgICAgICAgICAgLnRoZW4oKHJlc3BvbnNlQXJnKSA9PiB7XHJcbiAgICAgICAgICAgICAgICBsZXQgZmlsdGVyZWRSZXNwb25zZSA9IHJlc3BvbnNlQXJnLnJlc3VsdC5maWx0ZXIoKHJlY29yZEFyZykgPT4ge1xyXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAocmVjb3JkQXJnLnR5cGUgPT0gdHlwZUFyZyAmJiByZWNvcmRBcmcubmFtZSA9PSBkb21haW5OYW1lQXJnKTsgXHJcbiAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICB9KVxyXG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XHJcbiAgICB9O1xyXG4gICAgY3JlYXRlUmVjb3JkKGRvbWFpbk5hbWVBcmc6c3RyaW5nLHR5cGVBcmc6c3RyaW5nLGNvbnRlbnRBcmc6c3RyaW5nKXtcclxuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xyXG4gICAgICAgIHRoaXMuZ2V0Wm9uZUlkKGRvbWFpbk5hbWVBcmcpXHJcbiAgICAgICAgICAgIC50aGVuKChkb21haW5JZEFyZyk9PntcclxuICAgICAgICAgICAgICAgIGxldCBkYXRhSnNvbiA9IHtcclxuICAgICAgICAgICAgICAgICAgICBuYW1lOiBkb21haW5OYW1lQXJnLFxyXG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IHR5cGVBcmcsXHJcbiAgICAgICAgICAgICAgICAgICAgY29udGVudDogY29udGVudEFyZ1xyXG4gICAgICAgICAgICAgICAgfTtcclxuICAgICAgICAgICAgICAgIHRoaXMucmVxdWVzdChcIlBPU1RcIixcIi96b25lcy9cIiArIGRvbWFpbklkQXJnICsgXCIvZG5zX3JlY29yZHNcIixkYXRhSnNvbilcclxuICAgICAgICAgICAgICAgICAgICAudGhlbihmdW5jdGlvbihyZXNwb25zZUFyZyl7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUucmVzb2x2ZShyZXNwb25zZUFyZyk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XHJ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LmF1dGhLZXlcclxuICAgICAgICAgICAgfSxcclxuICAgICAgICAgICAgYm9keTpqc29uQXJnXHJcbiAgICAgICAgfTtcclxuICAgICAgICBwbHVnaW5zLnJlcXVlc3Qob3B0aW9ucyxmdW5jdGlvbihlcnIsIHJlcywgYm9keSl7XHJcbiAgICAgICAgICAgIGlmICghZXJyICYmIHJlcy5zdGF0dXNDb2RlID09IDIwMCkge1xyXG4gICAgICAgICAgICAgICAgdmFyIHJlc3BvbnNlT2JqID0gSlNPTi5wYXJzZShib2R5KTtcclxuICAgICAgICAgICAgICAgIGRvbmUucmVzb2x2ZShyZXNwb25zZU9iaik7XHJcbiAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhlcnIpO1xyXG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2cocmVzKTtcclxuICAgICAgICAgICAgICAgIGRvbmUucmVqZWN0KGVycik7XHJcbiAgICAgICAgICAgIH07XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcclxuICAgIH1cclxufTsiXX0= diff --git a/dist/cflare.classes.helpers.d.ts b/dist/cflare.classes.helpers.d.ts index e69de29..62d7805 100644 --- a/dist/cflare.classes.helpers.d.ts +++ b/dist/cflare.classes.helpers.d.ts @@ -0,0 +1 @@ +import "typings-global"; diff --git a/dist/cflare.classes.helpers.js b/dist/cflare.classes.helpers.js index 53fb469..c9a2d56 100644 --- a/dist/cflare.classes.helpers.js +++ b/dist/cflare.classes.helpers.js @@ -1,3 +1,4 @@ "use strict"; +require("typings-global"); -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJjZmxhcmUuY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlc0NvbnRlbnQiOltdfQ== +//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNmbGFyZS5jbGFzc2VzLmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQSIsImZpbGUiOiJjZmxhcmUuY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcclxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9jZmxhcmUucGx1Z2luc1wiKTsiXX0= diff --git a/dist/cflare.plugins.d.ts b/dist/cflare.plugins.d.ts index ccda423..97dfb0f 100644 --- a/dist/cflare.plugins.d.ts +++ b/dist/cflare.plugins.d.ts @@ -1,3 +1,4 @@ +import "typings-global"; export declare let beautylog: any; export declare let q: any; export declare let request: any; diff --git a/dist/cflare.plugins.js b/dist/cflare.plugins.js index 4077c00..96cd72d 100644 --- a/dist/cflare.plugins.js +++ b/dist/cflare.plugins.js @@ -1,7 +1,7 @@ "use strict"; -/// +require("typings-global"); exports.beautylog = require("beautylog"); exports.q = require("q"); exports.request = require("request"); -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNmbGFyZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDakMsaUJBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUM7QUFDakMsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNqQixlQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDIiwiZmlsZSI6ImNmbGFyZS5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxyXG5leHBvcnQgbGV0IGJlYXV0eWxvZyA9IHJlcXVpcmUoXCJiZWF1dHlsb2dcIik7XHJcbmV4cG9ydCBsZXQgcSA9IHJlcXVpcmUoXCJxXCIpO1xyXG5leHBvcnQgbGV0IHJlcXVlc3QgPSByZXF1aXJlKFwicmVxdWVzdFwiKTsiXX0= +//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNmbGFyZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDYixpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNqQyxTQUFDLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGVBQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUMiLCJmaWxlIjoiY2ZsYXJlLnBsdWdpbnMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiO1xyXG5leHBvcnQgbGV0IGJlYXV0eWxvZyA9IHJlcXVpcmUoXCJiZWF1dHlsb2dcIik7XHJcbmV4cG9ydCBsZXQgcSA9IHJlcXVpcmUoXCJxXCIpO1xyXG5leHBvcnQgbGV0IHJlcXVlc3QgPSByZXF1aXJlKFwicmVxdWVzdFwiKTsiXX0= diff --git a/dist/index.d.ts b/dist/index.d.ts index 426510e..e91b1e5 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1 +1,2 @@ +import "typings-global"; export { CflareAccount } from "./cflare.classes.cflareaccount"; diff --git a/dist/index.js b/dist/index.js index 86126a2..ec817e0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,6 +1,6 @@ "use strict"; -/// +require("typings-global"); var cflare_classes_cflareaccount_1 = require("./cflare.classes.cflareaccount"); exports.CflareAccount = cflare_classes_cflareaccount_1.CflareAccount; -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDNUMsNkNBQTRCLGdDQUFnQyxDQUFDO0FBQXJELHFFQUFxRCIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cclxuZXhwb3J0IHtDZmxhcmVBY2NvdW50fSBmcm9tIFwiLi9jZmxhcmUuY2xhc3Nlcy5jZmxhcmVhY2NvdW50XCI7Il19 +//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsNkNBQTRCLGdDQUFnQyxDQUFDO0FBQXJELHFFQUFxRCIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCI7XHJcbmV4cG9ydCB7Q2ZsYXJlQWNjb3VudH0gZnJvbSBcIi4vY2ZsYXJlLmNsYXNzZXMuY2ZsYXJlYWNjb3VudFwiOyJdfQ== diff --git a/package.json b/package.json index 3b480f4..bff9083 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,14 @@ }, "homepage": "https://github.com/pushrocks/cflare#readme", "dependencies": { - "beautylog": "^5.0.0", + "beautylog": "^5.0.6", "q": "^1.4.1", - "request": "^2.72.0" + "request": "^2.72.0", + "typings-global": "^1.0.3" }, "devDependencies": { - "npmts": "^5.1.5", - "should": "^8.3.1" + "npmts": "^5.1.13", + "should": "^8.4.0", + "typings-test": "^1.0.1" } } diff --git a/test/test.d.ts b/test/test.d.ts index e69de29..e7cc8ee 100644 --- a/test/test.d.ts +++ b/test/test.d.ts @@ -0,0 +1 @@ +import "typings-test"; diff --git a/test/test.js b/test/test.js index d6a27cf..79bd228 100644 --- a/test/test.js +++ b/test/test.js @@ -1,5 +1,5 @@ "use strict"; -/// +require("typings-test"); var cflare = require("../dist/index"); var should = require("should"); var nogit = require("../nogit/nogit.json"); @@ -22,7 +22,7 @@ describe("cflare", function () { }); describe(".getZoneId(domainName)", function () { it("should get an Cloudflare Id for a domain string", function (done) { - this.timeout(5000); + this.timeout(10000); testCflareAccount.getZoneId("push.rocks") .then(function (responseArg) { console.log(responseArg); @@ -32,7 +32,7 @@ describe("cflare", function () { }); describe(".listRecords(domainName)", function () { it("should list all records for a specific Domain Name", function (done) { - this.timeout(5000); + this.timeout(10000); testCflareAccount.listRecords("push.rocks") .then(function (responseArg) { console.log(responseArg); @@ -40,7 +40,17 @@ 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(); + }); + }); + }); }); }); -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLGdEQUFnRDtBQUNoRCxJQUFPLE1BQU0sV0FBVyxlQUFlLENBQUMsQ0FBQztBQUN6QyxJQUFJLE1BQU0sR0FBRyxPQUFPLENBQUMsUUFBUSxDQUFDLENBQUM7QUFDL0IsSUFBSSxLQUFLLEdBQUcsT0FBTyxDQUFDLHFCQUFxQixDQUFDLENBQUM7QUFFM0MsSUFBSSxpQkFBaUIsR0FBRyxJQUFJLE1BQU0sQ0FBQyxhQUFhLEVBQUUsQ0FBQztBQUNuRCxpQkFBaUIsQ0FBQyxJQUFJLENBQUM7SUFDbkIsS0FBSyxFQUFFLEtBQ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lKXtcclxuICAgICAgICAgICAgICAgIHRoaXMudGltZW91dCgxMDAwMCk7XHJcbiAgICAgICAgICAgICAgICB0ZXN0Q2ZsYXJlQWNjb3VudC5saXN0Wm9uZXMoKVxyXG4gICAgICAgICAgICAgICAgICAgIC50aGVuKChyZXNwb25zZUFyZyk9PntcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2cocmVzcG9uc2VBcmcpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBkb25lKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSlcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgZGVzY3JpYmUoXCIuZ2V0Wm9uZUlkKGRvbWFpbk5hbWUpXCIsZnVuY3Rpb24oKXtcclxuICAgICAgICAgICAgaXQoXCJzaG91bGQgZ2V0IGFuIENsb3VkZmxhcmUgSWQgZm9yIGEgZG9tYWluIHN0cmluZ1wiLGZ1bmN0aW9uKGRvbmUpe1xyXG4gICAgICAgICAgICAgICAgdGhpcy50aW1lb3V0KDUwMDApXHJcbiAgICAgICAgICAgICAgICB0ZXN0Q2ZsYXJlQWNjb3VudC5nZXRab25lSWQoXCJwdXNoLnJvY2tzXCIpXHJcbiAgICAgICAgICAgICAgICAgICAgLnRoZW4oKHJlc3BvbnNlQXJnKT0+e1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhyZXNwb25zZUFyZyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgZGVzY3JpYmUoXCIubGlzdFJlY29yZHMoZG9tYWluTmFtZSlcIixmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICBpdChcInNob3VsZCBsaXN0IGFsbCByZWNvcmRzIGZvciBhIHNwZWNpZmljIERvbWFpbiBOYW1lXCIsZnVuY3Rpb24oZG9uZSl7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnRpbWVvdXQoNTAwMCk7XHJcbiAgICAgICAgICAgICAgICB0ZXN0Q2ZsYXJlQWNjb3VudC5saXN0UmVjb3JkcyhcInB1c2gucm9ja3NcIilcclxuICAgICAgICAgICAgICAgICAgICAudGhlbigocmVzcG9uc2VBcmcpID0+IHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2cocmVzcG9uc2VBcmcpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBkb25lKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0pXHJcbiAgICB9KVxyXG59KTtcclxuIl19 +//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsSUFBTyxNQUFNLFdBQVcsZUFBZSxDQUFDLENBQUM7QUFDekMsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDO0FBQy9CLElBQUksS0FBSyxHQUFHLE9BQU8sQ0FBQyxxQkFBcUIsQ0FBQyxDQUFDO0FBRTNDLElBQUksaUJBQWlCLEdBQUcsSUFBSSxNQUFNLENBQUMsYUFBYSxFQUFFLENBQUM7QUFDbkQsaUJBQWlCLENBQUMsSUFBSSxDQUFDO0lBQ25CLEtBQUssRUFBRSxLQUFLLENBQUMsT0FBTztJQUNwQixHQUFHLEVBQUUsS0FBSyxDQUFDLEtBQUs7Q0FDbkIsQ0FBQyxDQUFDO0FBRUgsUUFBUSxDQUFDLFFBQVEsRUFBQztJQUNkLFFBQVEsQ0FBQyxnQkFBZ0IsRUFBQztRQUN0QixRQUFRLENBQUMsY0FBYyxFQUFDO1lBQ3BCLEVBQUUsQ0FB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gICBkZXNjcmliZShcIi5DZmxhcmVBY2NvdW50XCIsZnVuY3Rpb24oKXtcclxuICAgICAgICBkZXNjcmliZShcIi5saXN0Wm9uZXMoKVwiLGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIGl0KFwic2hvdWxkIGRpc3BsYXkgYW4gYWNjb3VudFwiLGZ1bmN0aW9uKGRvbmUpe1xyXG4gICAgICAgICAgICAgICAgdGhpcy50aW1lb3V0KDEwMDAwKTtcclxuICAgICAgICAgICAgICAgIHRlc3RDZmxhcmVBY2NvdW50Lmxpc3Rab25lcygpXHJcbiAgICAgICAgICAgICAgICAgICAgLnRoZW4oKHJlc3BvbnNlQXJnKT0+e1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhyZXNwb25zZUFyZyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcclxuICAgICAgICAgICAgICAgICAgICB9KVxyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9KTtcclxuICAgICAgICBkZXNjcmliZShcIi5nZXRab25lSWQoZG9tYWluTmFtZSlcIixmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICBpdChcInNob3VsZCBnZXQgYW4gQ2xvdWRmbGFyZSBJZCBmb3IgYSBkb21haW4gc3RyaW5nXCIsZnVuY3Rpb24oZG9uZSl7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnRpbWVvdXQoMTAwMDApXHJcbiAgICAgICAgICAgICAgICB0ZXN0Q2ZsYXJlQWNjb3VudC5nZXRab25lSWQoXCJwdXNoLnJvY2tzXCIpXHJcbiAgICAgICAgICAgICAgICAgICAgLnRoZW4oKHJlc3BvbnNlQXJnKT0+e1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhyZXNwb25zZUFyZyk7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUoKTtcclxuICAgICAgICAgICAgICAgICAgICB9KTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgZGVzY3JpYmUoXCIubGlzdFJlY29yZHMoZG9tYWluTmFtZSlcIixmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICBpdChcInNob3VsZCBsaXN0IGFsbCByZWNvcmRzIGZvciBhIHNwZWNpZmljIERvbWFpbiBOYW1lXCIsZnVuY3Rpb24oZG9uZSl7XHJcbiAgICAgICAgICAgICAgICB0aGlzLnRpbWVvdXQoMTAwMDApO1xyXG4gICAgICAgICAgICAgICAgdGVzdENmbGFyZUFjY291bnQubGlzdFJlY29yZHMoXCJwdXNoLnJvY2tzXCIpXHJcbiAgICAgICAgICAgICAgICAgICAgLnRoZW4oKHJlc3BvbnNlQXJnKSA9PiB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKHJlc3BvbnNlQXJnKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgZG9uZSgpO1xyXG4gICAgICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICB9KTtcclxuICAgICAgICB9KVxyXG4gICAgICAgIGRlc2NyaWJlKFwiLmNyZWF0ZVJlY29yZFwiLGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIHRoaXMudGltZW91dCgxMDAwMCk7XHJcbiAgICAgICAgICAgIGl0KFwic2hvdWxkIGNyZWF0ZSBhIHZhbGlkIHJlY29yZCBmb3IgYSBkb21haW5cIixmdW5jdGlvbihkb25lKXtcclxuICAgICAgICAgICAgICAgIHRlc3RDZmxhcmVBY2NvdW50LmNyZWF0ZVJlY29yZChcImJsZXUuZGVcIixcIkFcIixcIjEyNy4wLjAuMVwiKVxyXG4gICAgICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uKHJlc3BvbnNlQXJnKXtcclxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2cocmVzcG9uc2VBcmcpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBkb25lKCk7XHJcbiAgICAgICAgICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgICAgIH0pO1xyXG4gICAgICAgIH0pO1xyXG4gICAgfSlcclxufSk7XHJcbiJdfQ== diff --git a/test/test.ts b/test/test.ts index 6d36e8b..0831898 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,4 +1,4 @@ -/// +import "typings-test"; import cflare = require("../dist/index"); let should = require("should"); let nogit = require("../nogit/nogit.json"); @@ -23,7 +23,7 @@ describe("cflare",function(){ }); describe(".getZoneId(domainName)",function(){ it("should get an Cloudflare Id for a domain string",function(done){ - this.timeout(5000) + this.timeout(10000) testCflareAccount.getZoneId("push.rocks") .then((responseArg)=>{ console.log(responseArg); @@ -33,7 +33,7 @@ describe("cflare",function(){ }); describe(".listRecords(domainName)",function(){ it("should list all records for a specific Domain Name",function(done){ - this.timeout(5000); + this.timeout(10000); testCflareAccount.listRecords("push.rocks") .then((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(); + }) + }); + }); }) }); diff --git a/ts/cflare.classes.cflareaccount.ts b/ts/cflare.classes.cflareaccount.ts index 4ed5060..50b55a9 100644 --- a/ts/cflare.classes.cflareaccount.ts +++ b/ts/cflare.classes.cflareaccount.ts @@ -1,4 +1,4 @@ -/// +import "typings-global"; import plugins = require("./cflare.plugins"); import helpers = require("./cflare.classes.helpers"); @@ -41,21 +41,34 @@ export class CflareAccount { }) return done.promise; }; - createRecord(){ + createRecord(domainNameArg:string,typeArg:string,contentArg:string){ 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; }; - removeRecord(){ + removeRecord(domainNameArg:string,typeArg:string){ let done = plugins.q.defer(); + return done.promise; }; updateRecord(domainNameArg:string,typeArg:string,valueArg){ let done = plugins.q.defer(); return done.promise; }; - listRecords(domainName:string){ + listRecords(domainNameArg:string){ let done = plugins.q.defer(); - this.getZoneId(domainName) + this.getZoneId(domainNameArg) .then((domainIdArg)=>{ this.request("GET","/zones/" + domainIdArg + "/dns_records?per_page=100") .then(function(responseArg){ @@ -76,8 +89,9 @@ export class CflareAccount { }); return done.promise; }; - request(methodArg:string,routeArg:string,jsonArg?){ + request(methodArg:string,routeArg:string,dataArg = {}){ let done = plugins.q.defer(); + let jsonArg:string = JSON.stringify(dataArg); let options = { method:methodArg, url:"https://api.cloudflare.com/client/v4" + routeArg, @@ -86,7 +100,7 @@ export class CflareAccount { "X-Auth-Email":this.authEmail, "X-Auth-Key":this.authKey }, - json:jsonArg + body:jsonArg }; plugins.request(options,function(err, res, body){ if (!err && res.statusCode == 200) { diff --git a/ts/cflare.classes.helpers.ts b/ts/cflare.classes.helpers.ts index b53edbe..7290ae6 100644 --- a/ts/cflare.classes.helpers.ts +++ b/ts/cflare.classes.helpers.ts @@ -1,2 +1,2 @@ -/// +import "typings-global"; import plugins = require("./cflare.plugins"); \ No newline at end of file diff --git a/ts/cflare.plugins.ts b/ts/cflare.plugins.ts index 0480258..755b1ec 100644 --- a/ts/cflare.plugins.ts +++ b/ts/cflare.plugins.ts @@ -1,4 +1,4 @@ -/// +import "typings-global"; export let beautylog = require("beautylog"); export let q = require("q"); export let request = require("request"); \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts index ce09afb..b39f42f 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,2 +1,2 @@ -/// +import "typings-global"; export {CflareAccount} from "./cflare.classes.cflareaccount"; \ No newline at end of file