-
Notifications
You must be signed in to change notification settings - Fork 11
@@ -- Add Express V4 Support to @salesforce/mrt-utilities package.
#334
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c09aa66
Initial Commit
bendvc c00eddb
Update CHANGELOG.md
bendvc 7cfe512
Change peer to have a wider support range for 4.x
bendvc ac18a77
Revert manual changelog update; replace with changeset
bendvc 2545889
Add some docs to better understand this pattern
bendvc ebcdd6d
No monkey patching
bendvc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@salesforce/mrt-utilities': patch | ||
| --- | ||
|
|
||
| Add Express 4 support, improve middleware error handling, and add dual-version Express test coverage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * Copyright (c) 2025, Salesforce, Inc. | ||
| * SPDX-License-Identifier: Apache-2 | ||
| * For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0 | ||
| */ | ||
|
|
||
| import express5 from 'express'; | ||
| import {createRequire} from 'node:module'; | ||
|
|
||
| /* | ||
| * Load Express v4 via an npm alias so tests can run against v4 and v5 | ||
| * in the same process without altering production imports. | ||
| */ | ||
| const require = createRequire(import.meta.url); | ||
| const express4 = require('express4') as typeof express5; | ||
|
|
||
| /* | ||
| * Export both versions for parameterized test suites. | ||
| */ | ||
| export const expressVersions = [ | ||
| {label: 'express4', express: express4}, | ||
| {label: 'express5', express: express5}, | ||
| ]; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the reason for the change here, I am just curious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We made that change so this middleware works in Express 4.
Express 4 doesn’t always handle async errors, so we now call processIncomingRequest(...) and only call next() after it finishes, and if it fails we pass the error to next(err). This keeps the same behaviour but avoids unhandled promise errors. The function signature isn't changed, so we don't have a breaking change.