[nodejs] Re: Promise Unhandled rejection null

2015-12-18 Thread AndDM
Hi, thanks for your reply, i've edit my code in:

module.exports.run = function(event, context, cb) {
  myclass.queryAsync(...)
 .then(function (results) {
   if (results.field === "test") {
 return cb("error");
   } else {
 return cb(null, "success");
   }
 })
 .catch(function (err) {
   return cb(err)
 });
};
The error is te same.
Best regards


Il giorno giovedì 17 dicembre 2015 05:08:38 UTC+1, Ebrahim Pasbani ha 
scritto:
>
> You shouldn't throw exception in a callback.
> Instead throwing of that exception call 
> cb(error)
>
>
>
> On Thursday, 17 December 2015 04:40:56 UTC+3:30, AndDM wrote:
>>
>> Hi, i've this code:
>>
>> module.exports.run = function(event, context, cb) {
>>   myclass.queryAsync(...)
>>   .then(function (results) {
>> if (results.field === "test") {
>>   throw "error";
>> } else {
>>   return cb(null, "success");
>> }
>>   })
>>   .catch(function (err) {
>> return cb(err)
>>   });
>> };
>>
>> for promise i'm using bluebirdjs and i've attached this code to a mocha 
>> test. If function give back a success, the test passes without problems. If 
>> the test has errors, the stdout give back: Unhandled rejection null, the 
>> mocha test goes on and then stops with exceeded timeout limit.
>>
>> My mocha test:
>>   before("Description", function(done) {
>> require('path').run(event.options, {}, function (err, results) {
>>   if (err) {
>> throw err;
>>   }
>>   done();
>> });
>>   });
>>   
>>
>> Some suggestions about that?
>> Thanks for your time.
>> Best regards
>>
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/c7ee7cd9-113d-4f72-93e7-c4e1861ab99d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: JSdom append to body and render as an ejs view

2015-12-18 Thread Jimb Esser
I don't know anything about jsdom, but from what you said it sounds like 
you're trying to set up a server, to which you can request 
http://myhost/?url=otherhost.com/page.html and it returns that page, and 
then when that pages fetches style.css, it's failing.  You need to rewrite 
what is returned so that on the very first request instead of letting 
otherhost.com/page.html reference "style.css", it instead references a 
valid URL that will get what it needs, e.g. a mapped url that goes through 
your server: http://myhost/?url=otherhost.com/style.css (or, probably just 
"/?url=otherhost.com/style.css").  I have no idea how you'd do that with 
jsdom, but it probably involves changing all hrefs to relative paths to be 
prefixed with "/?url=otherhost.com/" or something.  Without remapping those 
paths, it's trying to fetch the stylesheet from your server, not forwarding 
the request on appropriately.

Hope this helps!
  Jimb Esser

On Wednesday, December 16, 2015 at 5:10:56 PM UTC-8, Roy Mor wrote:
>
> Still struggling with this problem, looking for someone who could shed a 
> light and help me u derstand.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/9ff71a2a-9590-4924-837b-8ceff91aef4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] node native/nan questions

2015-12-18 Thread Axel Kittenberger
I'm just trying to understand nan/node native extensions.

First question, class hierachy when wrapping C++ stuff.

Is unwrapping a static cast? (So far I guess so ) or can it in fact be a
dynamic cast?

Say I got in C++ Wrapper AClass and Wrapper BClass that both inherit
from Wrapper MasterClass.

Can I put in

NAN_METHOD( myFunc )
{
   MasterClass *mc = Nan::ObjectWrap::Unwrap( info[ 0
]->ToObject( ) );
}

and have it work when javascript hands a Wrapper for AClass or BClass?

If not, how can I determine which type of wrapped object javascript handed
to myFunc?

Second question:

How can I throw an javascript Exception from native if its simple sync code
without I/O. Usually should do when the arguments are not what they need to
be.

Kind regards, Axel

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CABg07fvu-V0shhDGB5wS3SeegG-z_ut6D%2BaoYrNQGVUtx3KK%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Promise Unhandled rejection null

2015-12-18 Thread Tim Davis
If there is an error in your test, be sure to pass it to done(err) so that the 
test doesn't time out.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/6cdfd764-fd8d-4b5e-bfc6-715561162512%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Trying to build a MUD that allows Telnet and Web socket connections

2015-12-18 Thread Zlatko
Since it's a different protocol, your socket.io would listen on another port.

So, I guess the game api itself is on abstract enough to be accepting player 
input and sending output in a common way, your connections protocols have to 
hook into this abstract API.

Now, socket connections and telnet ones should all be wrapped into object 
streams, I think (and I think socket.io basically is like an object stream).

That way on ticks your game engine doesn't care where it sends stuff data. And 
it doesn't care how the data comes in as it's always passed to the game engine 
in the same way.

And your both com protocols don't care what the data is, they just need to know 
they're wrapping client side into object stream and converting server data back 
into whatever is needed.

That way you can later add other protocols as well, like pure http (POST for 
input, sse endpoint for output or so).

I'm very curious how it turned out for you - is your project available online?

Former addict here :)

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/b1a0261f-5a8a-4475-88fd-03f1df723080%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: Promise Unhandled rejection null

2015-12-18 Thread Tim Davis
In your test, done has to be called to avoid timing out. In mocha if your 
unit under test causes an unexpected error, then you call done with that 
error so mocha can tell you. Here is a revision that calls `done` with the 
error.

before("Description", function(done) {
  require('path').run(event.options, {}, function (err, results) {
if (err) {
  return done(err); // <- call done and avoid double callback
}
return done();
  });
});

Also, it is better to use real errors.

module.exports.run = function(event, context, cb) {
  myclass.queryAsync(...)
 .then(function (results) {
   if (results.field === "test") {
 return cb(new Error("error"));
   } else {
 return cb(null, "success");
   }
 })
 .catch(function (err) {
   return cb(err)
 });
};



On Friday, December 18, 2015 at 9:02:26 AM UTC-8, AndDM wrote:
>
> Hi, thanks for your reply, i've edit my code in:
>
> module.exports.run = function(event, context, cb) {
>   myclass.queryAsync(...)
>  .then(function (results) {
>if (results.field === "test") {
>  return cb("error");
>} else {
>  return cb(null, "success");
>}
>  })
>  .catch(function (err) {
>return cb(err)
>  });
> };
> The error is te same.
> Best regards
>
>
> Il giorno giovedì 17 dicembre 2015 05:08:38 UTC+1, Ebrahim Pasbani ha 
> scritto:
>>
>> You shouldn't throw exception in a callback.
>> Instead throwing of that exception call 
>> cb(error)
>>
>>
>>
>> On Thursday, 17 December 2015 04:40:56 UTC+3:30, AndDM wrote:
>>>
>>> Hi, i've this code:
>>>
>>> module.exports.run = function(event, context, cb) {
>>>   myclass.queryAsync(...)
>>>   .then(function (results) {
>>> if (results.field === "test") {
>>>   throw "error";
>>> } else {
>>>   return cb(null, "success");
>>> }
>>>   })
>>>   .catch(function (err) {
>>> return cb(err)
>>>   });
>>> };
>>>
>>> for promise i'm using bluebirdjs and i've attached this code to a mocha 
>>> test. If function give back a success, the test passes without problems. If 
>>> the test has errors, the stdout give back: Unhandled rejection null, the 
>>> mocha test goes on and then stops with exceeded timeout limit.
>>>
>>> My mocha test:
>>>   before("Description", function(done) {
>>> require('path').run(event.options, {}, function (err, results) {
>>>   if (err) {
>>> throw err;
>>>   }
>>>   done();
>>> });
>>>   });
>>>   
>>>
>>> Some suggestions about that?
>>> Thanks for your time.
>>> Best regards
>>>
>>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/66183516-5056-4775-b7ff-b9261efc240d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: JSdom append to body and render as an ejs view

2015-12-18 Thread Roy Mor
I see. I thought maybe of serving the remote server files from my node 
server. Do you know maybe a way to download the remote website to a local 
directory on the node server and I'll edit the html so that my css and js 
files will be relative to where the website directory is stored?
Also if I do such thing, and serving the files from my node server, I would 
also need to deal with CORS. Do you know of a way I can intercept the any 
http OPTION request that is done by the browser and change the origin 
header to set it to the remote server?

בתאריך יום שישי, 18 בדצמבר 2015 בשעה 19:02:37 UTC+2, מאת Jimb Esser:
>
> I don't know anything about jsdom, but from what you said it sounds like 
> you're trying to set up a server, to which you can request 
> http://myhost/?url=otherhost.com/page.html and it returns that page, and 
> then when that pages fetches style.css, it's failing.  You need to rewrite 
> what is returned so that on the very first request instead of letting 
> otherhost.com/page.html reference "style.css", it instead references a 
> valid URL that will get what it needs, e.g. a mapped url that goes through 
> your server: http://myhost/?url=otherhost.com/style.css (or, probably 
> just "/?url=otherhost.com/style.css").  I have no idea how you'd do that 
> with jsdom, but it probably involves changing all hrefs to relative paths 
> to be prefixed with "/?url=otherhost.com/" or something.  Without 
> remapping those paths, it's trying to fetch the stylesheet from your 
> server, not forwarding the request on appropriately.
>
> Hope this helps!
>   Jimb Esser
>
> On Wednesday, December 16, 2015 at 5:10:56 PM UTC-8, Roy Mor wrote:
>>
>> Still struggling with this problem, looking for someone who could shed a 
>> light and help me u derstand.
>
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/24999672-4c17-4d4d-9fc8-61dd648dd306%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[nodejs] Re: Trying to build a MUD that allows Telnet and Web socket connections

2015-12-18 Thread mogill

>
> I'm very curious how it turned out for you - is your project available 
> online? 
>
> Former addict here :)


Ditto -- please support importing legacy PerlMUD 
 databases!

Node should be perfect for this sort of event-driven job, and make possible 
scripting features undreamt of in Perl!

-J

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/442cfb86-dc21-4d4b-ad71-503e644817c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.