-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation woes #4
Comments
This is all great feedback. I will leave the issue open as a hub for taking care of each of these points.
|
Another thing to document would be what Joey tries to be and its design philosophy. As far as I can tell it tries to be a reasonably thin chain creator leveraging q-io for the JSGI heavy lifting. |
+1. Perhaps this is a really stupid question but I am completely stuck trying to get my hands on the body of a POST, PUT etc. Just adding an example (unless I missed it) of here comes a POST request, and here is how to get at the body. I am still new to the world of nodejs, and have just been figuring out promises, so something obvious would be really great. |
@rohni Here's an example of parsing the values from a POST request: https://gist.github.com/Stuk/6861192. Note: this doesn't handle file uploads. |
@Stuk Thanks, that is actually really helpful. I actually worked it out over the weekend. Part of the problem was getting used to promises. Actually the next question was how to use joey as a client to send a post request to a web service. I finally gave up and just used node's http module. Interesting side track, was seeing how it would be pretty much impossible to use promises with http.request, as it expects a callback, and then you add your data to the request stream after it has been created. So, using something like q.nbind to tame it, will not work as you still need to get at the request object in order to add data to its stream. I am probably missing something. I put the code here: I guess, I am wondering how you would do this in joey, and/or failing that, make it promisified. I know you can use q.deferred on the returns from the callback, but that seems a bit like cheating. :) |
No problem. Take a look at @kriskowal's latest exciting work in the world of promise streams: kriskowal/q-io#57. As Joey is based on Q-IO this should solve your problem when it makes its way in. |
Yeah I couldn't quite figure out joey as a http client either, so I use q-io/http. var HTTP = require('q-io/http'); Wout. On Oct 11, 2013, at 15:54 , rohni notifications@github.com wrote:
|
@wmertens Cool thanks. I messed around with node's http.request and it took some puzzling, because you have a stream with events as well as the callback (which seems to just be another event underneath). Next time I am having to send post/put requests I will give it a shot. In the end I came up with this, which assumes you are dealing with json i.e. a json based web service: It works for what I need, and being able to use promises makes the other bits of my code much simpler. And I finally have a clue how to use q.defer(), which was the last big hole in my understanding. :) @Stuk I look forward to the new promise streams. They would make things very nice. |
I really like JSGI, I really like promises and therefore I want to really like Joey, but it's hard to get going with it 😕
I'm requesting a more thorough documentation than the set of examples that the readme has. Obviously, many functions are missing documentation altogether, but it goes deeper.
I understand the basics, but a definition for Joey applications and middleware would be nice. http://jackjs.org/writing-jsgi-applications.html and http://jackjs.org/writing-jsgi-middleware.html were somewhat helpful but still different from Joey. For example, the q-io middleware factories seem to return
fn(request, response)
but I don't understand why the response would ever be used.The way a Joey chain is built is also quite peculiar. I think it would be helpful to show what the call tree looks like for a simple Joey app and how it gets built up.
(When I make a middleware that works with .use(myMW) and do joey.install({mw: myMW})...mw()... it will crash when trying to apply on undefined. Is that supposed to work? It doesn't reference next on the applied function?)
Others:
The text was updated successfully, but these errors were encountered: