X Tutup
Skip to content

refactor(server)!: convert some public methods to private#149

Merged
chenjiahan merged 1 commit intomainfrom
private_methods_0310
Mar 10, 2026
Merged

refactor(server)!: convert some public methods to private#149
chenjiahan merged 1 commit intomainfrom
private_methods_0310

Conversation

@chenjiahan
Copy link
Member

The change converts several public methods to private by prefixing them with '#', improving encapsulation and reducing the public API surface. This helps maintain a cleaner interface and prevents unintended usage of internal methods.

Copilot AI review requested due to automatic review settings March 10, 2026 07:30
Copy link

Copilot AI left a comment

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 reduces the public API surface of the Server class by converting a set of previously-public (but internally used) instance methods into ECMAScript private methods (prefixed with #). This improves encapsulation by preventing external callers (and subclasses) from invoking or overriding internal lifecycle/utility methods.

Changes:

  • Converted multiple internal Server instance methods (e.g. option normalization, app/server initialization, websocket setup, stats/logging helpers, host/origin helpers) to # private methods.
  • Updated all in-class call sites to use this.#methodName(...) and adjusted bound middleware usage accordingly.

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

@gemini-code-assist
Copy link
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 Server class by converting numerous internal methods from public to private. This change enhances the class's encapsulation, making its internal workings less exposed and preventing external misuse. The primary goal is to improve code maintainability and clarify the intended public interface of the Server class.

Highlights

  • Encapsulation Improvement: Converted 22 methods within the Server class from public to private using the '#' prefix, significantly enhancing encapsulation.
  • API Surface Reduction: Reduced the public API surface of the Server class, making its internal implementation details less accessible and preventing unintended external usage.
  • Internal Call Updates: Updated all internal calls to the newly privatized methods to correctly reference them with their '#' prefix.

🧠 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
  • src/server.ts
    • Converted addAdditionalEntries, getCompilerOptions, shouldLogInfrastructureInfo, normalizeOptions, getClientTransport, getServerTransport, setupProgressPlugin, initialize, setupApp, getStats, setupHooks, setupWatchStaticFiles, setupWatchFiles, setupMiddlewares, setHeaders, createServer, createWebSocketServer, isSameOrigin, openBrowser, logStatus, isHostAllowed, and sendStats methods to private class fields.
    • Modified all internal invocations of these methods to use their new private '#' syntax.
Activity
  • No specific activity has been recorded for this pull request yet.
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.

Copy link
Contributor

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

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 Server class by converting multiple public methods to private using the # syntax. This change improves encapsulation by reducing the public API surface. All internal calls to these methods have been updated accordingly. The change is correctly marked as a breaking change. The refactoring has been applied consistently, and I found no issues with the implementation.

@chenjiahan chenjiahan merged commit f204f0c into main Mar 10, 2026
7 checks passed
@chenjiahan chenjiahan deleted the private_methods_0310 branch March 10, 2026 07:42
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

X Tutup