Skip to content

Upgrade to Express v5 #2685

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

Merged
merged 18 commits into from
Apr 30, 2025
Merged

Upgrade to Express v5 #2685

merged 18 commits into from
Apr 30, 2025

Conversation

cprecioso
Copy link
Member

@cprecioso cprecioso commented Apr 17, 2025

Description

Fixes #2593
Fixes #1632

Updates Express to v5
We're not impacted by most of the changes, only one thing:

We had a helper for that in our codebase (handleRejection), which is now unnecessary. I was going to remove it but our code is dependent on this function in order to correctly type req and res.

So I renamed it to defineHandler and made it a no-op, while updating its types to Express v5, so that we can keep it as it was.

Marked as a breaking change because users might had req and res calls that used some of the removed methods (as explained in the migration guide).

Select what type of change this PR introduces:

  1. Just code/docs improvement (no functional change).
  2. Bug fix (non-breaking change which fixes an issue).
  3. New feature (non-breaking change which adds functionality).
  4. Breaking change (fix or feature that would cause existing functionality to not work as expected).

Update Waspc ChangeLog and version if needed

If you did a bug fix, new feature, or breaking change, that affects waspc, make sure you satisfy the following:

  1. I updated ChangeLog.md with description of the change this PR introduces.
  2. I bumped waspc version in waspc.cabal to reflect changes I introduced, with regards to the version of the latest wasp release, if the bump was needed.

Update example apps if needed

If you did code changes and added a new feature or modified an existing feature, make sure you satisfy the following:

  1. I updated waspc/examples/todoApp as needed (updated modified feature or added new feature) and manually checked it works correctly.
  2. I updated waspc/headless-test/examples/todoApp and its e2e tests as needed (updated modified feature and its tests or added new feature and new tests for it).

@cprecioso cprecioso self-assigned this Apr 17, 2025
@@ -50,7 +50,7 @@ const defaultGlobalMiddleware = new Map([
['cors', cors({ origin: config.allowedCORSOrigins })],
['logger', logger('dev')],
['express.json', express.json()],
['express.urlencoded', express.urlencoded({ extended: false })],
['express.urlencoded', express.urlencoded()],
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Great stuff Carlos, I missed it in the code view for some reason 🤦

@cprecioso cprecioso requested review from infomiho and sodic and removed request for infomiho April 22, 2025 14:19
@cprecioso cprecioso marked this pull request as ready for review April 22, 2025 14:19
Copy link
Contributor

@infomiho infomiho left a comment

Choose a reason for hiding this comment

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

Left some comments

Tested out locally with the todoApp and open-saas, worked fine

@@ -17,7 +17,7 @@
"devDependencies": {
"@tailwindcss/forms": "^0.5.10",
"@tailwindcss/typography": "^0.5.16",
"@types/express": "^4.17.13",
"@types/express": "^5.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAIU we do that with the RC when we prepare for a release, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can do the change now and merge it before release or wait for the RC to do the change, I guess we don't have a rule about that 🤷

Context: Filip did this change #2691 and this PR wasp-lang/open-saas#419

Copy link
Contributor

Choose a reason for hiding this comment

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

@cprecioso what did you decide to do?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll prepare the PR now

EDIT: I think it's quite a small change actually and the compiler will guide us, better to do it when we update OpenSaas than to have such a simple PR left open for weeks

@cprecioso
Copy link
Member Author

@infomiho if everything is fine, we should be good to go with merging (tho @Martinsos removed it from the sprint so idk)

@Martinsos
Copy link
Member

@infomiho if everything is fine, we should be good to go with merging (tho @Martinsos removed it from the sprint so idk)

Oh we removed the PR only because there was issue already (with estimate and all), so to not have it duplicate! So it is still in the sprint, no worries.

@cprecioso cprecioso merged commit b411bc2 into main Apr 30, 2025
6 checks passed
@cprecioso cprecioso deleted the cprecioso/2593-migrate-to-express-5 branch April 30, 2025 11:03
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.

Migrate to Express 5 Use declare global to declare Wasp specific fields in the Express request
3 participants