-
Notifications
You must be signed in to change notification settings - Fork 27
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
Full doc listener? #51
Comments
I think you can just add in the copyright to the json document in a "get" listener. I'll look into adding another listener for right before sending, but I don't think that's necessary for this. |
Sorry I posted too soon by accident. Are you going to add a field to the output or are you going to add a header. Otherwise, just adding text before or after would break Jon parsing. |
Cool, thanks. Let's say I have several docs. Right now, they come in as an array. I'd like to be able to add everything to a root item like 'data'. Then, at the end, I'd like to add a copyright statement off the root. Something like 'copyright' :'message'. Having this global feature would let me manipulate the final json before its sent out, not just the document inside the array. Make sense? |
Yep, that makes perfect sense. Thanks for the detailed explanation! I've just committed a "getpresend" listener that does what you're looking for, but I haven't pushed out a new npm version because I'm not sure about the name yet. |
Nice! Let me take a look at it and I'll come back to you. What's in a name, right? :) |
Hey again. I can see the event firing correctly, but it doesn't seem as though I can manipulate the doc and pass it back to the response. Here's my bit of code:
I can't seem to manipulate and return the doc as I would expect to. Any suggestions on what I'm doing wrong? |
I think the problem here is that you're replacing the "doc" variable. Since JavaScript passes by value, the caller of your listener function doesn't see the change. There's two potential solutions.
Also, note that since you're not doing any async operations (e.g. file IO, network requests, database lookups) the promise is unnecessary. |
I understand how to add an expressa.addListener to each document, but I would like to know if there is a way to add a listener to expressa that happens right before the final response is sent.
I'd like to add a copyright message to the end of my entire result before it's sent to the client.
Can't quite figure it out. :/
The text was updated successfully, but these errors were encountered: