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

[ Demo ] @uppy/companion: express 5.0.0 compatibility #5457

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

maximilianschmid
Copy link

No description provided.

Copy link

socket-security bot commented Sep 12, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@angular-devkit/[email protected] Transitive: environment, eval, filesystem, network, shell, unsafe +430 628 MB angular, google-wombot
npm/@angular-eslint/[email protected] None +4 1.89 MB jameshenry
npm/@angular-eslint/[email protected] None +2 1.55 MB jameshenry
npm/@angular/[email protected] None 0 1.73 MB google-wombot
npm/@angular/[email protected] Transitive: environment, eval, filesystem, network, shell, unsafe +124 21.9 MB angular, google-wombot
npm/@angular/[email protected] None 0 11.5 MB angular, google-wombot
npm/@angular/[email protected] Transitive: environment, filesystem, network, shell, unsafe +30 7.42 MB google-wombot
npm/@angular/[email protected] None 0 9.24 MB angular, google-wombot
npm/@angular/[email protected] None 0 21.1 MB angular, google-wombot
npm/@angular/[email protected] None 0 1.98 MB angular, google-wombot
npm/@angular/[email protected] None 0 79.8 kB angular, google-wombot
npm/@angular/[email protected] None 0 773 kB angular, google-wombot
npm/@angular/[email protected] None 0 2.43 MB angular, google-wombot
npm/@parcel/[email protected] Transitive: environment, eval, filesystem, network, shell, unsafe +100 691 MB devongovett
npm/[email protected] None +1 30.2 kB dougwilson
npm/[email protected] Transitive: filesystem +11 509 kB fzuzzy
npm/[email protected] Transitive: environment, filesystem, network, shell +112 12.7 MB astone123, atofstryker, brian-mann, ...9 more
npm/[email protected] None 0 2.8 kB
npm/[email protected] environment +1 90.4 kB dougwilson
npm/[email protected] environment, filesystem +2 50 kB karmarunnerbot
npm/[email protected] Transitive: environment, filesystem, network, shell, unsafe +32 5.93 MB karmarunnerbot
npm/[email protected] None 0 8.84 kB dfederm
npm/[email protected] Transitive: filesystem +1 408 kB karmarunnerbot
npm/[email protected] environment, filesystem, network, shell Transitive: eval, unsafe +86 8.96 MB karmarunnerbot
npm/[email protected] environment Transitive: eval, filesystem, network, shell, unsafe +161 778 MB devongovett
npm/[email protected] None 0 15.3 kB cwmma
npm/[email protected] None +2 203 kB terkelg
npm/[email protected] environment +1 4.61 MB react-bot
npm/[email protected] Transitive: environment, filesystem +18 15.4 MB posva, soda, yyx990803

View full report↗︎

Copy link
Contributor

Diff output files
diff --git a/packages/@uppy/companion/lib/companion.js b/packages/@uppy/companion/lib/companion.js
index 9416e5e..25f3982 100644
--- a/packages/@uppy/companion/lib/companion.js
+++ b/packages/@uppy/companion/lib/companion.js
@@ -88,7 +88,7 @@ module.exports.app = (optionsArg = {}) => {
   // Making `POST` request to the `/connect/:provider/:override?` route requires a form body parser middleware:
   // See https://github.com/simov/grant#dynamic-http
   app.use(
-    "/connect/:oauthProvider/:override?",
+    "/connect/:oauthProvider/:override",
     express.urlencoded({ extended: false }),
     getCredentialsOverrideMiddleware(providers, options),
   );
@@ -102,7 +102,7 @@ module.exports.app = (optionsArg = {}) => {
   });
   app.use(middlewares.cors(options));
   // add uppy options to the request object so it can be accessed by subsequent handlers.
-  app.use("*", middlewares.getCompanionMiddleware(options));
+  app.use(/(.*)/, middlewares.getCompanionMiddleware(options));
   app.use("/s3", s3(options.s3));
   if (options.enableUrlEndpoint) {
     app.use("/url", url());
@@ -171,7 +171,7 @@ module.exports.app = (optionsArg = {}) => {
     middlewares.hasSimpleAuthProvider,
     controllers.simpleAuth,
   );
-  app.get("/:providerName/list/:id?", middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list);
+  app.get("/:providerName/list/:id", middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list);
   // backwards compat:
   app.get("/search/:providerName/list", middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list);
   app.post(

@maximilianschmid maximilianschmid changed the title [ Demo ] express 5.0.0 compatibility [ Demo ] @uppy/companion: express 5.0.0 compatibility Sep 12, 2024
@Murderlon
Copy link
Member

Hi, are you sure that there are no breaking changes for people integrating Companion into their own Express 4.x or people making custom providers?

If that would break some cases, this can't be merged as we won't do a another major for a while.

@Murderlon Murderlon requested a review from mifi October 15, 2024 08:08
Copy link
Contributor

@mifi mifi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be a breaking change and so needs a new major release of Companion

@@ -103,7 +103,7 @@ module.exports.app = (optionsArg = {}) => {
// override provider credentials at request time
// Making `POST` request to the `/connect/:provider/:override?` route requires a form body parser middleware:
// See https://github.com/simov/grant#dynamic-http
app.use('/connect/:oauthProvider/:override?', express.urlencoded({ extended: false }), getCredentialsOverrideMiddleware(providers, options))
app.use('/connect/:oauthProvider/:override', express.urlencoded({ extended: false }), getCredentialsOverrideMiddleware(providers, options))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at https://expressjs.com/en/guide/migrating-5.html#path-syntax i think wee need this instead?

Suggested change
app.use('/connect/:oauthProvider/:override', express.urlencoded({ extended: false }), getCredentialsOverrideMiddleware(providers, options))
app.use('/connect/:oauthProvider{/:override}', express.urlencoded({ extended: false }), getCredentialsOverrideMiddleware(providers, options))

source: https://www.npmjs.com/package/path-to-regexp#optional

@@ -117,7 +117,7 @@ module.exports.app = (optionsArg = {}) => {
app.use(middlewares.cors(options))

// add uppy options to the request object so it can be accessed by subsequent handlers.
app.use('*', middlewares.getCompanionMiddleware(options))
app.use(/(.*)/, middlewares.getCompanionMiddleware(options))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this should be

Suggested change
app.use(/(.*)/, middlewares.getCompanionMiddleware(options))
app.use(middlewares.getCompanionMiddleware(options))

@@ -132,7 +132,7 @@ module.exports.app = (optionsArg = {}) => {

app.post('/:providerName/simple-auth', express.json(), middlewares.hasSessionAndProvider, middlewares.hasBody, middlewares.hasSimpleAuthProvider, controllers.simpleAuth)

app.get('/:providerName/list/:id?', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list)
app.get('/:providerName/list/:id', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Suggested change
app.get('/:providerName/list/:id', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list)
app.get('/:providerName/list{/:id}', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list)

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

Successfully merging this pull request may close these issues.

3 participants