Comparing version 0.1.5 to 0.1.6
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"keywords": [ | ||
@@ -16,7 +16,7 @@ "dynect", | ||
], | ||
"bugs": { "url" : "https://github.com/ashleybrener/dynector/issues" }, | ||
"bugs": { "url" : "https://github.com/frisB/dynect/issues" }, | ||
"license": "MIT", | ||
"repository": { | ||
"type" : "git", | ||
"url" : "https://github.com/ashleybrener/dynector" | ||
"url" : "https://github.com/frisB/dynect" | ||
}, | ||
@@ -26,3 +26,3 @@ "dependencies": { | ||
}, | ||
"main": "./dynector", | ||
"main": "./index", | ||
"engines": { | ||
@@ -29,0 +29,0 @@ "node": ">= 0.8.x" |
@@ -9,10 +9,12 @@ Dyn DNS API connector for node.js. | ||
``` js | ||
var Dynect = require('dynect'); | ||
// open Dynect API session | ||
var dynector = new Dynector('customername', 'username', 'password'); | ||
var dynect = new Dynect('customername', 'username', 'password'); | ||
dynector.on('connected', function () { | ||
dynect.on('connected', function () { | ||
var zone = 'example.com'; | ||
// add A record with 5 min TTL | ||
dynector.addRecord('A', zone, 'www.example.com', { | ||
dynect.addRecord('A', zone, 'www.example.com', { | ||
address: '123.45.67.89' | ||
@@ -23,7 +25,7 @@ }, 300, function (addResponse) { | ||
//publish zone | ||
dynector.publishZone(zone, function (publishResponse) { | ||
dynect.publishZone(zone, function (publishResponse) { | ||
console.log(publishResponse); | ||
// close Dynect API session | ||
dynector.disconnect(); | ||
dynect.disconnect(); | ||
}); | ||
@@ -33,3 +35,3 @@ }); | ||
dynector.connect(); | ||
dynect.connect(); | ||
``` | ||
@@ -42,10 +44,12 @@ | ||
``` js | ||
var Dynect = require('dynect'); | ||
// open Dynect API session and send keepalive every 5mins | ||
var dynector = new Dynector('customername', 'username', 'password', 300000); | ||
var dynect = new Dynect('customername', 'username', 'password', 300000); | ||
dynector.on('connected', function () { | ||
dynect.on('connected', function () { | ||
var zone = 'example.com'; | ||
// add CNAME record with default TTL | ||
dynector.addRecord('CNAME', zone, 'www.example.com', { | ||
dynect.addRecord('CNAME', zone, 'www.example.com', { | ||
cname: 'example.mydomain.com' | ||
@@ -56,3 +60,3 @@ }, 0, function (addResponse) { | ||
// publish zone | ||
dynector.publishZone(zone, function (publishResponse) { | ||
dynect.publishZone(zone, function (publishResponse) { | ||
console.log(publishResponse); | ||
@@ -63,17 +67,11 @@ }); | ||
dynector.connect(); | ||
dynect.connect(); | ||
``` | ||
## Installation | ||
## installation | ||
### Installing npm (node package manager) | ||
``` | ||
curl http://npmjs.org/install.sh | sh | ||
npm install dynect | ||
``` | ||
### Installing dynector | ||
``` | ||
[sudo] npm install dynect | ||
``` | ||
#### Author: [Ashley Brener](http://twitter.com/ashleybrener) | ||
#### author: ashley @[frisB.com](http://www.frisb.com) |
var events = require('events'); | ||
var https = require('https'); | ||
var util = require('util'); | ||
var winston = require('winston'); | ||
var logger = new (winston.Logger)({ | ||
transports: [ | ||
new (winston.transports.Console)({ | ||
colorize: true, | ||
handleExceptions: true, | ||
timestamp: false | ||
}) | ||
], | ||
levels: { | ||
silly: 0, | ||
verbose: 1, | ||
info: 2, | ||
data: 3, | ||
warn: 4, | ||
debug: 5, | ||
error: 6 | ||
}, | ||
colors: { | ||
silly: 'blue', | ||
verbose: 'cyan', | ||
info: 'green', | ||
data: 'grey', | ||
warn: 'magenta', | ||
debug: 'yellow', | ||
error: 'red' | ||
} | ||
}); | ||
var Logger = require('./logger'); | ||
function Session(customer, username, password) { | ||
events.EventEmitter.call(this); | ||
this.logger = new Logger('Dynect Session'); | ||
this.openTime = null; | ||
@@ -49,3 +24,3 @@ this.customer = customer; | ||
send(null, 'POST', '/Session/', { | ||
this.send(null, 'POST', '/Session/', { | ||
data: { | ||
@@ -86,3 +61,3 @@ customer_name: this.customer, | ||
send(this.token, 'DELETE', '/Session/', {}, function (response) { | ||
this.send(this.token, 'DELETE', '/Session/', {}, function (response) { | ||
//{ status: 'success', | ||
@@ -111,3 +86,3 @@ // data: {}, | ||
send(this.token, 'GET', '/Session/', {}, function (response) { | ||
this.send(this.token, 'GET', '/Session/', {}, function (response) { | ||
//{ status: 'success', | ||
@@ -140,3 +115,3 @@ // data: {}, | ||
send(this.token, 'PUT', '/Session/', {}, function (response) { | ||
this.send(this.token, 'PUT', '/Session/', {}, function (response) { | ||
//{ status: 'success', | ||
@@ -164,2 +139,3 @@ // data: {}, | ||
if (this.token != null) { | ||
// session open for 50 mins | ||
if (Date.now() - this.openTime >= (50 * 60 * 1000)) { | ||
@@ -170,3 +146,3 @@ this.verify(function (err) { | ||
if (!err) { | ||
send(self.token, method, path, options, callback); | ||
self.send(self.token, method, path, options, callback); | ||
} | ||
@@ -178,3 +154,3 @@ }); | ||
else { | ||
send(this.token, method, path, options, callback); | ||
this.send(this.token, method, path, options, callback); | ||
} | ||
@@ -185,3 +161,3 @@ } | ||
if (!err) { | ||
send(self.token, method, path, options, callback); | ||
self.send(self.token, method, path, options, callback); | ||
} | ||
@@ -192,3 +168,4 @@ }); | ||
function send(token, method, path, options, callback) { | ||
Session.prototype.send = function (token, method, path, options, callback) { | ||
var self = this | ||
var opt = { | ||
@@ -244,6 +221,6 @@ host: 'api2.dynect.net', | ||
if (msg.ERR_CD != null) { | ||
winston.error(msg.ERR_CD + ' (' + msg.INFO + ')\n'); | ||
self.logger.error(msg.ERR_CD + ' (' + msg.INFO + ')\n'); | ||
} | ||
else { | ||
winston.info(msg.INFO + '\n'); | ||
self.logger.info(msg.INFO + '\n'); | ||
} | ||
@@ -253,3 +230,3 @@ } | ||
else { | ||
winston.info(response + '\n'); | ||
self.logger.info(response + '\n'); | ||
} | ||
@@ -262,3 +239,3 @@ | ||
catch (e) { | ||
winston.error('[request exception] ' + e.message + '\n\n' + data); | ||
self.logger.error('request exception: ' + e.message + '\n\n' + data); | ||
} | ||
@@ -269,6 +246,6 @@ }); | ||
req.on('error', function (e) { | ||
winston.error('[request] ' + e); | ||
self.logger.error('request: ' + e); | ||
}); | ||
winston.info(method + ' https://' + opt.host + opt.path); | ||
this.logger.info(method + ' https://' + opt.host + opt.path); | ||
@@ -275,0 +252,0 @@ if ((method === 'POST' || method === 'PUT') && options.data) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
15661
481
1
71
3