fvdm / nodejs-dnsimple

REPO MOVED TO DNSIMPLE, see url:
https://www.npmjs.com/package/dnsimple
The Unlicense
16 stars 3 forks source link

Implementing checker function to index page #1

Closed jhvst closed 12 years ago

jhvst commented 12 years ago

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!

fvdm commented 12 years ago

When you load the module directly from a file you need to include the .js extension, like this:

dnsimple = require('./node_modules/dnsimple.js')

The domain registration and SSL certificate related methods are not yet implemented as I use only the DNS methods myself. However, I do have complete implementation high on my priority list. Maybe I have time in a couple of days.

jhvst commented 12 years ago

For some reason it gives me the very same error. I fixed the path in app.js, I wonder was I supposed to do that?

Also, I'm hosting my project at nodejitsu, if that matters.

fvdm commented 12 years ago

I have no experience with their platform, but usually you could simply run 'npm install dnsimple' on your commandline and then load the module into your code with:

var dnsimple = require( 'dnsimple' )

What operating system are you using?

jhvst commented 12 years ago

I'm under CentOS, but I've already ran that command locally. Also, I tried adding the dnsimple file under scripts in package.json, which currently looks like this:

{
  "name": "*****",
  "author": {
    "name": "JH",
    "email": "j***@mail.com"
  },
  "version": "0.1.1-97",
  "scripts": {
    "start": "./app.js",
    "dnsimple": "./node_modules/dnsimple/dnsimple.js"
  },
  "dependencies": {
    "express": "2.5.9",
    "jade": ">= 0.0.1",
    "dnsimple": "0.1.2"
  },
  "analyze": false,
  "devDependencies": {},
  "optionalDependencies": {},
  "engines": {
    "node": "0.6.x"
  },
  "subdomain": "*****"
}

I try to get Chromium up on my CentOS VM in case I could run it locally.

jhvst commented 12 years ago

Got over that, but now I'm receiving the following at my console:

[06/14 17:27:11 GMT+0300] [ReferenceError: directvps is not defined]
[06/14 17:27:11 GMT+0300]     at EventEmitter._tickCallback (node.js:190:38)
[06/14 17:27:11 GMT+0300]     at Array.0 (tls.js:792:22)
[06/14 17:27:11 GMT+0300]     at CleartextStream.emit (events.js:64:17)
[06/14 17:27:11 GMT+0300]     at CleartextStream.socketCloseListener (http.js:1173:9)
[06/14 17:27:11 GMT+0300]     at ClientRequest.emit (events.js:67:17)
[06/14 17:27:11 GMT+0300]     at ClientRequest. (/usr/local/src/jhsto/myproject/package/node_modules/dnsimple/dnsimple.js:477:3)
[06/14 17:27:11 GMT+0300] ReferenceError: directvps is not defined

Should I be including the dnsimple.js in my source?

My current server-side code:

everyone.now.dnsimple = function(){
  dnsimple.api.email = 'j****@mail.com';
  dnsimple.api.token = 'you shall not see this!';
  dnsimple.dns.show( 'one.com', function () {
    console.log('DNSimple responded something.');
  });
};

And client-side:

now.dnsimple();
fvdm commented 12 years ago

Oh dear, the error handling got mixed up with another project! That should never happen.

I have updated the code [a2a216c7a22330d5c40218525a44848e3a0a169e] and NPM. Please run npm update to get the fix or redownload from github if you do it that way.

My apologies for the trouble.

fvdm commented 12 years ago

Oops I rushed things a bit, updated again (v0.1.4) SHA: 2c30c426d888d15caa8dc2b472b25666b97da704

jhvst commented 12 years ago

Thanks! It is almost working, since it seems like I'm facing another issue:

[06/14 20:54:20 GMT+0300] { [Error: socket hang up] code: 'ECONNRESET' }
[06/14 20:54:20 GMT+0300]     at EventEmitter._tickCallback (node.js:190:38)
[06/14 20:54:20 GMT+0300]     at Array.0 (tls.js:792:22)
[06/14 20:54:20 GMT+0300]     at CleartextStream.emit (events.js:64:17)
[06/14 20:54:20 GMT+0300]     at CleartextStream.socketCloseListener (http.js:1173:23)
[06/14 20:54:20 GMT+0300]     at createHangUpError (http.js:1124:15)
[06/14 20:54:20 GMT+0300] Error: socket hang up

Looks like they are either blocking me, or something else is up.

While I'm trying to deal with this, could there be a chance to code the registration functions too? I would be grateful for those.

PS: Just in case you haven't noticed it yourself, this project is little more than unofficial by now: https://dnsimple.com/documentation/api as you can see, your project is listed there under node.js :)

PSS: Thank you for helping me this far!

fvdm commented 12 years ago

ECONNRESET sounds like a network or remote problem. It works fine for me from multiple systems and networks. Maybe you could contact DNSimple, perhaps they blocked your API access for increased error rate or something.

While I'm trying to deal with this, could there be a chance to code the registration functions too? I would be grateful for those.

I'm working on it ;)

PS: Just in case you haven't noticed it yourself, this project is little more than unofficial by now: https://dnsimple.com/documentation/api as you can see, your project is listed there under node.js :)

Wow I didn't know, that's awesome :)

jhvst commented 12 years ago

OK, so I got the ECONNRESET thing worked out. It turned out to be a slight misunderstanding in my code.

I don't want to push you or anything, but for now I'm just waiting for you to finish up the registration addons, which I was looking after in the first place.

fvdm commented 12 years ago

I'm working on it at this very moment in the DomainRegistration branch.

It would be great if you could try them out :)

jhvst commented 12 years ago

Thanks, it seems to work properly at the moment. I'm about to put it into a true firetest later this evening and we shall see how it performs. Thus far it has been really fast, if not else. Great work! :)

Also, I got some errors, but these may just be because of some immense amount of my request I tried to make:

[TypeError: undefined is not a function]
TypeError: undefined is not a function
    at /home/juuso/Dropbox/node/node_modules/dnsimple/dnsimple.js:190:4
    at IncomingMessage.<anonymous> (/home/juuso/Dropbox/node/node_modules/dnsimple/dnsimple.js:585:6)
    at IncomingMessage.emit (events.js:88:20)
    at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:130:23)
    at CleartextStream.socketOnData [as ondata] (http.js:1288:20)
    at CleartextStream._push (tls.js:375:27)
    at SecurePair.cycle (tls.js:734:20)
    at EncryptedStream.write (tls.js:130:13)
    at Socket.ondata (stream.js:38:26)
    at Socket.emit (events.js:67:17)

What more of, this happened like 1/100, but I thought to throw it up here anyway.

fvdm commented 12 years ago

At line 190 is the domains.register callback calling. Those 1/100 that result to this error, do they set the callback function or perhaps do or do not use extendedAttribute?

jhvst commented 12 years ago

Yes you are right, I do not use extendedAttribute.