Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

chore(server): upgrade to Express 5 and drop body-parser#1170

Merged
silverbucket merged 1 commit into
mastersockethub/sockethub:masterfrom
chore/express-5sockethub/sockethub:chore/express-5Copy head branch name to clipboard
Jul 5, 2026
Merged

chore(server): upgrade to Express 5 and drop body-parser#1170
silverbucket merged 1 commit into
mastersockethub/sockethub:masterfrom
chore/express-5sockethub/sockethub:chore/express-5Copy head branch name to clipboard

Conversation

@silverbucket

Copy link
Copy Markdown
Member

Summary

  • Upgrade express 4.22 → 5.x (and @types/express → v5)
  • Replace the standalone body-parser dependency with the bundled express.json() / express.urlencoded()
  • Fix the one Express 5 breaking change in our code: the app.get("*") examples SPA fallback

Why

Express 5 forwards rejected promises from async route handlers to error middleware, which removes an entire class of process-crashing unhandled rejections (Express 4 does not catch these). body-parser is exactly what Express bundles as express.json()/express.urlencoded(), so the separate dependency is redundant.

Changes

  • express^5.1.0, @types/express^5.0.0; removed body-parser and @types/body-parser.
  • listener.ts: bodyParser.urlencoded/jsonexpress.urlencoded/json; app.get("*", …)app.get(/.*/, …) (path-to-regexp v8 no longer accepts the bare "*" string).
  • Literal resource routes in routes.ts are unaffected (no wildcard/:param patterns).

Verification

  • Full unit suite passes (610 tests).
  • Booted the server and confirmed base resource routes, the examples SPA fallback (the new regex route), and the socket.io endpoint all serve 200 with no startup errors.
  • socket.io rate-limiter integration suite passes against the Express 5 server.

Notes

The related rate-limit-redis idea (shared cross-instance rate limits) is intentionally not in this PR. Master's only express-rate-limit user is the examples static-file limiter, where per-instance in-memory limiting is actually the correct behavior — the endpoint that benefits from shared limits is the HTTP actions API on #1036, so rate-limit-redis will land there instead.

Once this merges, #1036 (HTTP actions) will rebase onto Express 5 and can drop its defensive try/catch around the async POST handler, since Express 5 handles async rejections natively.

- Bump express 4.22 -> 5.x (and @types/express to v5). Express 5 forwards
  rejected promises from async route handlers to error middleware, removing a
  class of process-crashing unhandled rejections.
- Replace the standalone body-parser dependency with the bundled
  express.json()/express.urlencoded() (body-parser is what Express uses
  internally); drop body-parser and @types/body-parser.
- Replace the app.get("*") examples SPA fallback with app.get(/.*/): Express 5 /
  path-to-regexp v8 no longer accept the bare "*" string path.

Verified: server boots, base resource routes, the examples SPA fallback, and
the socket.io endpoint all serve; full unit suite passes.
@github-actions github-actions Bot added scope:server Issues related to Sockethub Server package type:chore Maintenance tasks labels Jul 5, 2026
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@silverbucket, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 132fe7f8-a74a-4735-bc5c-368506a5f323

📥 Commits

Reviewing files that changed from the base of the PR and between 53b79f3 and 2bbf767.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • packages/server/package.json
  • packages/server/src/listener.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/express-5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@silverbucket silverbucket self-assigned this Jul 5, 2026
@silverbucket silverbucket added the kredits-1 Small contribution label Jul 5, 2026
@silverbucket

Copy link
Copy Markdown
Member Author

@coderabbitai code review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
gh pr view 1170 --repo sockethub/sockethub --json title,body,files,additions,deletions
echo "-----DIFF-----"
gh pr diff 1170 --repo sockethub/sockethub

Length of output: 109356


🏁 Script executed:

#!/bin/bash
sed -n '1,220p' packages/server/src/listener.ts

Length of output: 6653


@silverbucket Reviewed the diff for #1170. This is a clean, well-scoped upgrade:

packages/server/package.json

  • express^5.1.0, @types/express^5.0.0; body-parser/@types/body-parser removed — correct, since Express 5 bundles body-parser@2.x internally (confirmed in bun.lock).
  • express-rate-limit@8.2.1's peer dependency (express >= 4.11) is satisfied by Express 5, so no compatibility concern there.

packages/server/src/listener.ts

  • bodyParser.urlencoded/jsonexpress.urlencoded/json: straightforward, behavior-preserving swap.
  • app.get("*", limiter, ...)app.get(/.*/, limiter, ...): correctly addresses the path-to-regexp v8 breaking change, with a clear explanatory comment.
  • I traced the route registration order: routes.setup(app) runs before this.addExamplesRoutes(app) in start(), so the wildcard SPA fallback is registered last and won't shadow the literal resource routes in routes.ts. This lines up with your verification notes.
  • Middleware ordering is preserved (express.static → rate-limited catch-all), so static assets are still served before falling back to index.html.

No functional or structural issues found. This looks safe to merge based on the diff alone; nice, minimal, and well-documented change.

[approve]

@silverbucket
silverbucket merged commit b8a7fd1 into master Jul 5, 2026
19 checks passed
@silverbucket
silverbucket deleted the chore/express-5 branch July 5, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kredits-1 Small contribution scope:server Issues related to Sockethub Server package type:chore Maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.