Skip to content

Update Express tutorial to v5 #40247

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 11 commits into from
Jul 18, 2025
Merged

Conversation

hamishwillee
Copy link
Collaborator

@hamishwillee hamishwillee commented Jul 8, 2025

This updates the Express Tutorial to v5

I wrote some tests in mdn/express-locallibrary-tutorial#327, then updated Express to v5 along with all dependencies - everything passed. Then ran all the code mods (npx @expressjs/codemod upgrade) suggested in the migration guide - nothing was changed. So I don't think I was using anything impacted by a changed or removed API.

I have updated the docs now. Mostly this was removing code to do async error handling in routes using asyncHandler since Express now handles that automatically. Also updated the Express sections on handling errors so this is more clear.
The route path handling is also different, so I had to update that section - it wasn't anything I was using in the demo, but it was significant for readers.

I also updated the database connection to to be done in bin/www since that allows for testing.
The way it was done in the app.js means that tests can't work (because you can't have multiple connections, and if you do this in the app there is already a connection by the time you get to the test runner).

Last of all I went through the lot and checked all the docs and versions of libraries. I did not retest the deployment though (mostly because I did that fairly recently).

Actions:

Fixes #38922

@github-actions github-actions bot added Content:Learn Learning area docs size/m [PR only] 51-500 LoC changed labels Jul 8, 2025
Copy link
Contributor

github-actions bot commented Jul 8, 2025

Preview URLs (23 pages)
External URLs (17)

URL: /en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs
Title: Express web framework (Node.js/JavaScript)


URL: /en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/Displaying_data/Home_page
Title: Home page


URL: /en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/forms/Update_Book_form
Title: Update Book form


URL: /en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/Introduction
Title: Express/Node introduction


URL: /en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/routes
Title: Express Tutorial Part 4: Routes and controllers


URL: /en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/skeleton_website
Title: Express Tutorial Part 2: Creating a skeleton website

(comment last updated: 2025-07-16 08:07:12)

@github-actions github-actions bot added size/l [PR only] 501-1000 LoC changed and removed size/m [PR only] 51-500 LoC changed labels Jul 14, 2025
@hamishwillee hamishwillee marked this pull request as ready for review July 15, 2025 07:45
@hamishwillee hamishwillee requested a review from a team as a code owner July 15, 2025 07:45
@hamishwillee hamishwillee requested review from chrisdavidmills and removed request for a team July 15, 2025 07:45
@hamishwillee hamishwillee requested a review from bsmth July 15, 2025 07:46
Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

@hamishwillee sterling work, sir. I've read through all the changes and made a few suggestions, but nothing major.

A couple of questions:

  • Do you need me to run through it all and make sure it all works, or have you already done this with confidence? I'm assuming you have, but happy to help with this if not.
  • I've not checked in detail whether you've missed any instances of mass replaced terms such as 4x -> 5x, but I'm assuming you've grepped for these?

@@ -345,11 +342,12 @@ The **package.json** file defines the application dependencies and other informa
"debug": "~2.6.9",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need a jade dependency if it is now called pug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. I will fix

Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot added the merge conflicts 🚧 [PR only] label Jul 15, 2025
@github-actions github-actions bot removed the merge conflicts 🚧 [PR only] label Jul 15, 2025
@hamishwillee
Copy link
Collaborator Author

@chrisdavidmills - I have accepted all your changes, a couple with minor mods. Thanks so much.

Do you need me to run through it all and make sure it all works, or have you already done this with confidence? I'm assuming you have, but happy to help with this if not.

I don't think this is necessary - though the offer appreciated!

For the bits where code changes, mostly this was just removal of the asyncHandler which is no longer needed. I have retested those bits match the demo code for the "final version". I haven't run through every step from scratch - e.g., starting from the original empty handlers that we build on, but this was more or less a search and replace so I'm not concerned.

I've not checked in detail whether you've missed any instances of mass replaced terms such as 4x -> 5x, but I'm assuming you've grepped for these?

Yes it was a grep.

Upshot, I am pretty confident of this. Should be good to go. mdn/express-locallibrary-tutorial#327 should merge at a similar time.

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

@hamishwillee woo hoo — awesome work!

I'm approving this, but I won't merge it. I'll let you do that once the other related PR is ready to go too.

@hamishwillee hamishwillee merged commit 8443cb3 into mdn:main Jul 18, 2025
8 of 10 checks passed
@hamishwillee
Copy link
Collaborator Author

Thanks @chrisdavidmills . It's all good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Learn Learning area docs size/l [PR only] 501-1000 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Express tutorial needs upgrade to v5
2 participants