Skip to content

feat!: replace express with connect as default server - #143

Merged
chenjiahan merged 2 commits into
mainfrom
connect_0309
Mar 9, 2026
Merged

chenjiahan merged 2 commits into
mainfrom
connect_0309

Conversation

@chenjiahan

@chenjiahan chenjiahan commented Mar 9, 2026

Copy link
Copy Markdown
Member

Use Connect instead of Express for the default dev server.

The dev server only needs a minimal middleware pipeline. Connect provides the same (req, res, next) interface as Express while being significantly smaller and having fewer dependencies, making it a better fit for this use case.

webpack/webpack-dev-server#4741 (comment)

Rsbuild / Vite also use Connect as the default dev server.

Copilot AI review requested due to automatic review settings March 9, 2026 08:54
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the default development server to use Connect instead of Express. This change aims to reduce the server's footprint and dependencies, as Connect provides a more minimal middleware pipeline while maintaining a compatible interface for basic use cases. The update includes modifications to dependencies, type definitions, and documentation to reflect this transition.

Highlights

  • Default Dev Server Change: The default development server now utilizes Connect instead of Express for its underlying application, aiming for a more minimal and efficient setup.
  • Dependency Optimization: Connect is adopted for its smaller size and fewer dependencies, making it a more suitable choice for a minimal middleware pipeline compared to Express.
  • Migration Guidance: Documentation has been updated to guide users who previously relied on Express-specific APIs, advising them to explicitly provide an Express app if their custom logic requires it.
  • Type System Updates: Internal type definitions have been adjusted across the codebase to reflect the transition from Express to Connect, ensuring type safety with the new framework.
  • Static File Serving: The static file serving middleware has been updated to use serve-static directly with Connect, aligning with the new server architecture.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docs/migrate-v1-to-v2.md
    • Updated the 'Upgraded Express to v5' section title to 'Default app now uses connect'.
    • Added detailed explanation for the switch to Connect and guidance for users needing Express-specific APIs.
  • package.json
    • Added @types/connect, connect, and serve-static to dependencies.
    • Removed express from dependencies.
    • Removed @types/express from devDependencies.
    • Added express to devDependencies.
  • pnpm-lock.yaml
    • Updated dependency lock file to reflect changes in package.json, including the addition of connect and serve-static and the removal of express from direct dependencies.
  • rslib.config.ts
    • Modified externals configuration to use connect instead of express and added serve-static.
  • src/server.ts
    • Removed ExpressApplication import and type usage.
    • Imported ConnectApplication and used it as the default BasicApplication type.
    • Replaced getExpress with getConnect and introduced getServeStatic.
    • Updated the default app creation to use getConnect()().
    • Changed static middleware names from express-static to serve-static and used getServeStatic().static.
    • Adjusted type assertions for MiddlewareObject and MiddlewareHandler.
  • src/types.ts
    • Removed all Express-related type imports and exports (ExpressApplication, ExpressRequest, ExpressResponse, ExpressRequestHandler, ExpressErrorRequestHandler).
    • Added ConnectApplication and ConnectIncomingMessage type imports and exports.
    • Updated Request and Response types to be based on ConnectIncomingMessage and ServerResponse.
    • Simplified MiddlewareHandler and MiddlewareObject interfaces to be framework-agnostic.
    • Updated comment from 'express-like use' to 'connect-like use'.
  • tests/e2e/on-listening.test.js
    • Refactored the onListening callback to use devServer.app.use with a Connect-style middleware function instead of Express-specific app.get and app.post methods.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@chenjiahan chenjiahan changed the title refactor: replace express with connect as default server feat!: replace express with connect as default server Mar 9, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the dev server to use connect instead of express by default, which is a great move for reducing dependencies and aligning with other tools like Vite and Rsbuild. The changes are well-executed across the documentation, dependencies, and source code. I've found a couple of areas for improvement regarding dependency management and type safety. My detailed feedback is in the comments below.

Comment thread package.json
Comment thread src/types.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces Express with Connect as the default application for the dev server. The motivation is that Connect is significantly smaller and has fewer dependencies than Express, while providing the same (req, res, next) middleware interface that the dev server actually needs.

Changes:

  • Swaps express from dependencies to devDependencies (only needed for testing custom app scenarios), adds connect and serve-static as new explicit dependencies
  • Replaces all Express-specific types (ExpressApplication, ExpressRequest, etc.) with Connect equivalents and simplifies MiddlewareHandler to a generic function type
  • Updates the default app creation from getExpress()() to getConnect()(), replaces getExpress().static(...) with standalone getServeStatic()(...), and updates the test for onListening to use the connect-compatible app.use() instead of app.get()/app.post()

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/server.ts Replaces getExpress with getConnect and getServeStatic; updates type defaults from ExpressApplication to ConnectApplication
src/types.ts Imports connect types, removes Express-specific type imports, simplifies MiddlewareHandler, MiddlewareObject, and Middleware
package.json Moves express to devDependencies, adds connect, serve-static, and @types/connect to dependencies
pnpm-lock.yaml Reflects updated dependency graph
rslib.config.ts Replaces express external with connect and serve-static externals
tests/e2e/on-listening.test.js Updates route handler from Express-specific app.get()/app.post() to connect-compatible app.use() with manual method checking
docs/migrate-v1-to-v2.md Documents the breaking change and provides migration guidance for users relying on Express-specific APIs
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/server.ts
@chenjiahan
chenjiahan merged commit 7bf5b45 into main Mar 9, 2026
3 checks passed
@chenjiahan
chenjiahan deleted the connect_0309 branch March 9, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants