Skip to content

Express Routes: Migrate to v5 pathing (breaking changes) #29592

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

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

Conversation

MaoShizhong
Copy link
Contributor

@MaoShizhong MaoShizhong commented Apr 6, 2025

Because

Express v5 is now the latest npm release, i.e. it's now what learners will end up installing when they run npm install express. There aren't too many breaking changes in v5 but there are some with routes and paths. Breaking changes elsewhere, such as async middleware and error-catching, will not be addressed in this PR.

This PR

  • Replaces ?/()/* example with new examples using {} (v5 optional chars) and *splat (new splat format that requires a name and matches slightly differently from before).
  • Amends any existing paths as necessary
  • Removes redundant id (duplicate id generated by note box heading already)
  • Add note in assignment about v4/5 contents compatibility.
    • Currently, there doesn't seem to be a v5-only routing primer, so for now the mixed v4/5 primer with links to v5-only parts will have to do. I imagine in due course, Express will update docs and there will be a cleaner v5-only primer to link to if not the same URL. There are a couple of areas in Express docs that they are aware aren't yet up to scratch for v5 only.

Issue

N/A
Closes #29638

Additional Information

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project curriculum contributing guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • If any lesson files are included in this PR, they follow the Layout Style Guide

Some characters no longer compatible with v5
v5 splat usage differs from v4's
@github-actions github-actions bot added the Content: NodeJS Involves the NodeJS course label Apr 6, 2025
@rlmoser99 rlmoser99 requested review from a team and bycdiaz and removed request for a team April 6, 2025 16:46
@MaoShizhong MaoShizhong marked this pull request as draft April 16, 2025 11:14
@MaoShizhong MaoShizhong marked this pull request as ready for review April 16, 2025 11:30
@MaoShizhong
Copy link
Contributor Author

With v5's new splat matching, splats also appear in req.params though they match differently to params with : and so have different semantics.
I've opted to not delve into that in the lesson changes, as IMO it's unlikely many learners will run into a situation that mixes splats and route params in the same path, and even if one does, I'm confident they can explore it themselves (or with community help).

@MaoShizhong MaoShizhong changed the title Express Routes: Migrate to v5 pathing Express Routes: Migrate to v5 pathing (breaking changes) Apr 16, 2025
@01zulfi 01zulfi self-requested a review April 17, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content: NodeJS Involves the NodeJS course
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Routes: wildcard route needs a parameter to work with but is missing in the example in the lesson
1 participant