feat: add compression middleware and optimize serial port loading#4501
Merged
robertsLando merged 5 commits intozwave-js:masterfrom Feb 19, 2026
Merged
feat: add compression middleware and optimize serial port loading#4501robertsLando merged 5 commits intozwave-js:masterfrom
robertsLando merged 5 commits intozwave-js:masterfrom
Conversation
Pull Request Test Coverage Report for Build 20427107452Details
💛 - Coveralls |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves perceived performance of the Settings UI and reduces response payload sizes by enabling HTTP response compression and moving serial port enumeration out of the /api/settings payload into a dedicated endpoint.
Changes:
- Add Express
compressionmiddleware (threshold 1KB) to compress API/static responses. - Refactor
/api/settingsto no longer enumerate serial ports; introduce/api/serial-portsfor on-demand enumeration. - Update Settings view and client API wrapper to fetch serial ports separately and initialize them in the base store.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
api/app.ts |
Adds compression middleware; removes serial port enumeration from /api/settings; adds /api/serial-ports endpoint. |
src/views/Settings.vue |
Loads settings first, then triggers a separate serial ports fetch without blocking the settings UI. |
src/stores/base.js |
Makes serial_ports initialization conditional since /api/settings no longer always includes it. |
src/apis/ConfigApis.js |
Adds getSerialPorts() client method calling the new endpoint. |
package.json |
Adds compression dependency. |
package-lock.json |
Updates lockfile for the new dependency (plus additional metadata churn). |
Integrate master's managedExternally settings and ZWAVE_PORT check into the compress branch's separated serial-ports endpoint. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Member
|
@zackbcom I'm so sorry I have missed your PR, too many notifications when I came back from Christmas 😢 I'm fixing some things locally, thanks a lot for this improvement 🙏🏼 |
Add return in serial-ports catch block to prevent double response, and add @types/compression dev dependency for proper TS types. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
Author
|
Thank you! settings are so much snappier. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
It is currently taking 1 second plus to load the serial ports for me. (Docker container) Adding compression only sped it up a little, but the payload is much smaller now (compressed). Moved pulling serial to the settings page where it's only used.
If you don't want a breaking change on the api, could add a param to the api to exclude pulling serial.
This pull request improves the performance and maintainability of the API and frontend by introducing response compression and refactoring how serial port information is loaded. The serial ports are now fetched via a separate API endpoint, allowing the settings page to load faster without waiting for potentially slow serial port enumeration. Additionally, response compression is enabled to reduce bandwidth usage.
API Improvements:
compressionmiddleware to the Express app to compress all HTTP responses larger than 1KB, improving network efficiency. (api/app.ts,package.json) [1] [2] [3]/api/settingsendpoint to remove serial port enumeration, making it faster and more reliable. (api/app.ts) [1] [2]/api/serial-portsendpoint that asynchronously enumerates serial ports, returning results separately from settings. (api/app.ts)Frontend Improvements:
ConfigApismodule to add agetSerialPortsmethod for fetching serial port data from the new endpoint. (src/apis/ConfigApis.js)src/views/Settings.vue,src/stores/base.js) [1] [2]Introduce compression middleware to enhance response optimization and load serial ports separately in the settings view to improve performance. This change ensures that the settings page remains responsive while fetching serial port data.Screenshots