Giter Site home page Giter Site logo

fvdm / nodejs-dnsimple Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 3.0 262 KB

REPO MOVED TO DNSIMPLE, see url:

Home Page: https://www.npmjs.com/package/dnsimple

License: The Unlicense

JavaScript 96.70% Shell 3.30%
dnsimple dnsimple-v1 legacy api-client nodejs unlicense

nodejs-dnsimple's Introduction

dnsimple

This is an unofficial DNSimple API module for node.js. You need a DNSimple account to use this.

npm Build Status Dependency Status Coverage Status

Installation

npm install dnsimple

Example

See Configuration below for details.

var dnsimple = new require ('dnsimple') ({
  email: '[email protected]',
  token: 'abc123'
});

// Add a domain name
var input = {
  domain: { name: 'example.tld' }
};

dnsimple ('POST', '/domains', input, function (err, data) {
  if (err) {
    return console.log (err);
  }

  console.log (data.domain.name + ' created with ID ' + data.domain.id);
});

More examples: https://github.com/fvdm/nodejs-dnsimple/wiki

Authentication

This module supports multiple authentication methods. None of them is totally secure, but some are easier to reset.

Account token

Most secure, easy to reset at dnsimple.com/account.

var dnsimple = require ('dnsimple') ({
  email: '[email protected]',
  token: '12345abcde'
});

Email & password

var dnsimple = require ('dnsimple') ({
  email: '[email protected]',
  password: 'secret'
});

Domain token

Access to only one domain name, easy to reset.

var dnsimple = require ('dnsimple') ({
  domainToken: 'abc123'
});

Two-factor authentication (2FA / OTP)

When you have set up two-factor authentication for your account the module returns error twoFactorOTP missing when you did not provide your one-time password.

First your need to tell the API once your one-time code from Authy or SMS, by defining it during setup along with your email and password and calling a random method. Then the API returns a token which you can use instead of your email and password.

// Set the OTP code on load
var dnsimple = require ('dnsimple') ({
  email: '[email protected]',
  password: 'my-secret',
  twoFactorOTP: '0123456'
});

// Now call a random method to trade the OTP for a longterm token
dnsimple ('GET', '/subscription', function (err, data, meta) {
  if (err) { return console.log (err); }

  console.log ('Two-factor token: '+ meta.twoFactorToken);
});

// From now on only use this token - no email/password
var dnsimple = require ('dnsimple') ({
  twoFactorToken: '22596363b3de40b06f981fb85d82312e'
});

Configuration

When loading the module into your code you need to provide an Object for authentication as described above. This object can have a few more settings.

name description default
email Account email address
token Account access token
password Account password
domainToken Domain specific API access token
twoFactorOTP One-time code, i.e. Authy
twoFactorToken Login token, from twoFactorOTP
timeout End API call after this amount of ms 30000
hostname API endpoint api.dnsimple.com

To use the sandbox environment set hostname to api.sandbox.dnsimple.com.

dnsimple

( method, path, [params], callback )

The module is only one method which takes care of all the error handling and basic post-processing.

See the API documentation for details on each method.

Module Arguments

name type required description
method string yes GET, POST, PUT, DELETE
path string yes i.e. /domains/two.com
params object no i.e. {domain: { name: 'one.com' } }
callback function yes Function to receive response

Callback Arguments

The last argument callback receives three arguments: err, data and meta. When an error occurs err is an instance of Error and data is null. err can have additional properties. When everything is good err will be null and data will be the parsed result.

The meta parameter is always available and contains extra information from the API, such as statusCode, request_id, runtime and twoFactorToken.

  • DELETE result data is boolean true on success, false otherwise.

Errors

The err.message can be any of these:

message description additional
credentials missing No authentication details set
request failed The request cannot be made err.error
invalid reponse Invalid API response err.code, err.error, err.data
API error The API returned an error err.code, err.error, err.data

Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Author

Franklin van de Meent

nodejs-dnsimple's People

Contributors

anderly avatar fvdm avatar greenkeeperio-bot avatar weppos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nodejs-dnsimple's Issues

Thanks for writing this, but please adhere to the node.js conventions

First of all, thanks for publishing this. It is very helpful and saves me an hour or two. That is much appreciated.

However, please provide an update (with a significant new version) that changes the callback syntax from yours to the official node version, where the err is always the first parameter.

Thanks
Martin

Implementing checker function to index page

Hello,

I'm trying to use your module to check domain availability on my index.js page. However, I don't have much experience in node.js and I'm having hard time getting the the checker function to work.

My setup is running express as framework, sporting jade. This is what I have in the server-side so far:

var express = require('express')
  , routes = require('./routes')
  , dnsimple = require('./node_modules/dnsimple') 

....

// Configuration

dnsimple.api.email = 'j****@mail.com';
dnsimple.api.token = '*******************';

.....

So basically what I have tried to do is adding following into client side .jade file, inside script tags:

dnsimple.domains.show(domain);

where domain is post data of form. This however runs me into error saying "Uncaught ReferenceError: dnsimple is not defined ", which makes me confused where and how should I declare dnsimple function.

My current index.js looks like this:

exports.index = function(req, res, dnsimple){
  res.render('index', { title: 'Backnorder' })
};

I understand if you don't want to help a newbie, but any attempts to help would be really appreciated!

Multiple instances

Please wrap the API with config into an object so I can create multiple instances.

Thanks!

Complete v1 release

  • Restructure module
  • Rewrite test script
  • Rewrite readme
  • Run tests
  • Tag commits
  • Create releases
  • Move changelog to Github Releases

Build Status
Code Climate

Not working with api v1

I'm trying to use your package with a new command line interface for dnsimple (http://ander.ly/1eSUh). However, I've found it doesn't work with the current version of the api.

The host name should now be api.dnsimple.com and the path should be prefixed with /v1/.

A couple of other issues I've run into are the callback signature doesn't follow the standard function(err, callback) convention.

For instance, instead of:

callback( result, status );

I'd like to change it to:

callback( status, result );

or:

callback( null, result );

and include status as a property on the result.

I have forked your repo and could submit these back as a PR, but didn't know if you were tied to that model.

Let me know.

Massive clean up

note to self

I'm considering to redesign the whole interface, making it all much much easier to code and maintain.

Windows support

  • Does the test script run?

Update:
In Windows 7 I needed to install Git for Windows and run the command below from git bash to at least install from the dev tree.

npm install git+https://github.com/fvdm/nodejs-dnsimple

Add tests with Travis CI

  • Write test script in seperate branch: /Tests
  • Connect to Travis CI
  • Set up DNSimple Sandbox account
  • Run successful basic test
  • Add tests for individual methods

Part of v1 release (#5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.