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

Custom Middleware Reusability #334

Closed
1 of 6 tasks
cschuff opened this issue Aug 8, 2019 · 3 comments · Fixed by SAP/ui5-server#246
Closed
1 of 6 tasks

Custom Middleware Reusability #334

cschuff opened this issue Aug 8, 2019 · 3 comments · Fixed by SAP/ui5-server#246
Assignees
Labels
enhancement New feature or request module/ui5-server Related to the UI5 Server module

Comments

@cschuff
Copy link

cschuff commented Aug 8, 2019

Expected Behavior

Defining a custom middleware once should allow to reuse it in customMiddleware more than once. This might be achieved by giving middlewares an id (to reference custom middlewares) and a name (used for order and display).

Current Behavior

It fails with duplicate middleware name:

Error: Failed to add custom middleware proxy. A middleware with the same name is already known.
    at MiddlewareManager.addCustomMiddleware (/XXX/node_modules/@ui5/cli/node_modules/@ui5/server/lib/middleware/MiddlewareManager.js:159:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! XXX@1.0.0 start: `ui5 serve -p 3000`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the XXX@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Steps to reproduce the issue

  1. Create a simple custom middleware
  2. Register as custom middleware in ui5.yaml
  3. Use the newly registered middleware twice in ui5.yaml

Affected components (if known)

Log Output / Stack Trace

Error: Failed to add custom middleware proxy. A middleware with the same name is already known.
    at MiddlewareManager.addCustomMiddleware (/XXX/node_modules/@ui5/cli/node_modules/@ui5/server/lib/middleware/MiddlewareManager.js:159:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! XXX@1.0.0 start: `ui5 serve -p 3000`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the XXX@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@RandomByte
Copy link
Member

Hey @cschuff,

Could you please add some details on your use case? We discussed generating unique IDs for custom middlewares during their implementation. However, we were concerned how one could reference the middleware in the "customMiddleware" configuration without knowing the generated ID.

Why do you need the same middleware to be added multiple times? Is it to use different mount paths? Or a different order?

Thanks!

@cschuff
Copy link
Author

cschuff commented Aug 8, 2019

I have a generic proxy middleware that I re-use to proxy different backends. And yes, they need different mount paths. That's about it.

@vobu
Copy link

vobu commented Oct 11, 2019

tried it out - see SAP/ui5-server#246 (comment)
didn't work at first shot, probably did sth wrong though

vobu referenced this issue in ui5-community/ui5-ecosystem-showcase Oct 11, 2019
@RandomByte RandomByte transferred this issue from SAP/ui5-server Nov 20, 2020
@RandomByte RandomByte added enhancement New feature or request module/ui5-server Related to the UI5 Server module labels Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request module/ui5-server Related to the UI5 Server module
Projects
None yet
3 participants