Skip to content
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

feat: implement on:response hook #1453

Closed
wants to merge 1 commit into from
Closed

Conversation

Hebilicious
Copy link
Member

@Hebilicious Hebilicious commented Jul 17, 2023

πŸ”— Linked issue

Resolves #1396

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

WIP

There's a one issue with this implementation :

toNodeListener isn't compatible with defineNitroResponse, so the presets would need to be refactored to use localCall, or h3s toNodeListener would need to be updated to accept a callback function that can modify the response.

For the hook API name we could use extendResponse instead of modifyResponse

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pi0
Copy link
Member

pi0 commented Jul 17, 2023

I don't think implemeting hook this way would be the best idea. Also as you have noticed, only worker presets using localFetch could benefit this and this is against nitro goals.

@pi0
Copy link
Member

pi0 commented Jul 17, 2023

We have render:response to modify the hook already to modify renderer responses. For genetic hook, if we ever gonna support it, it might be coming from h3. Let's keep the discussion under #1396.

@pi0 pi0 closed this Jul 17, 2023
@pi0 pi0 deleted the add-on-response-hook branch July 17, 2023 13:27
@pi0
Copy link
Member

pi0 commented Jul 17, 2023

Upstream: unjs/h3#447

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

on:response Hook
2 participants