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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/@uppy/companion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@
"@aws-sdk/lib-storage": "^3.338.0",
"@aws-sdk/s3-presigned-post": "^3.338.0",
"@aws-sdk/s3-request-presigner": "^3.338.0",
"body-parser": "1.20.2",
"common-tags": "1.8.2",
"connect-redis": "7.1.1",
"content-disposition": "^0.5.4",
"cookie-parser": "1.4.6",
"cors": "^2.8.5",
"escape-goat": "3.0.0",
"escape-string-regexp": "4.0.0",
"express": "4.19.2",
"express": "5.0.0",
"express-interceptor": "1.2.0",
"express-prom-bundle": "7.0.0",
"express-session": "1.18.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/@uppy/companion/src/companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

app.use(Grant(grantConfig))

app.use((req, res, next) => {
Expand All @@ -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))

app.use('/s3', s3(options.s3))
if (options.enableUrlEndpoint) app.use('/url', url())

Expand All @@ -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)

// backwards compat:
app.get('/search/:providerName/list', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list)

Expand Down