-
-
Notifications
You must be signed in to change notification settings - Fork 127
changes: add option to manage response middleware #533
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
changes: add option to manage response middleware #533
Conversation
|
I don't know why is failing the CI 😢 I thinks a problem installing a package:
|
I believe it's due to the recent release of svelte V4. Please use "dev" branch as the source branch for making changes in the future, and it should work then :D. |
| logger: options.logger, | ||
| }); | ||
| response.status(r.status).json(marshalToObject(r.body, useSuperJson)); | ||
| if (manageCustomResponse) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure I understand how to use this. Since when manageCustomResponse is on the code here, simply returns the status and body, is it supposed to use the middleware like regular function call in a request handler then?
const zenstack = ZenStackMiddleware({ manageCustomResponse: true, ... });
app.all('/api/model/*', async (req, res) => {
const { status, body } = await zenstack(req, res);
// more processing
...
return res.status(status).json(body);
});|
Hi, yes @ymc9, this is the idea but I don't know why this is not working... I have pushed a new temporal test before merging with the other express tests with You can run only this test using this command from
The I am trying to figure out where is the problem... |
|
Hey @chemitaxis I think the problem is that when I feel the general pattern of express middleware, if not sending a response, is not to return some data - I'm not sure how the returned data would be used by subsequent middleware or route handler. Instead, should it attach information to |
|
Hi @ymc9 yes, exactly, there was the problem... I found it but I don't know why, I don't have notifications on my inbox when I get mentioned... I have created a test, what do you think? Best. |
|
this will be very useful @chemitaxis ! |
|
It looks great now! I'll merge it and publish a new version soon. Thank you! |
This PR solves this issue proposal: #531
:)