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

Expose HTTP Proxy middleware, so it can be used outside express #687

Closed
wants to merge 3 commits into from

Conversation

Legoless
Copy link

@Legoless Legoless commented Dec 21, 2021

The purpose of this PR is to make it possible to use the middleware outside Express. For example we integrated the library with NestJS using NestMiddleware and Fastify.

Description

This requires the change of middleware type to any (since there are no internal defined types that can be used instead for now). Additional method createProxy is added, which returns HttpProxyMiddleware, thus exposing the middleware directly, giving a bit more flexibility.

Motivation and Context

The only exposed method returns an Express RequestHandler object, which TypeScript does not recognize as callable in NestJS environment. Changing this to any allows it to be called from TypeScript.

How has this been tested?

Has been tested by deploying to internal servers and thoroughly connected with NestJS.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

The change is backward compatible and does not break any code.

@chimurai chimurai mentioned this pull request Feb 26, 2022
@cdaringe
Copy link

#721 does this properly. this PR should be closed. this is an abuse of any, respectfully

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.

None yet

3 participants