refactor: delegate options processing to a dedicated function#6333
Merged
Uzlopak merged 4 commits intofastify:mainfrom Sep 27, 2025
Merged
refactor: delegate options processing to a dedicated function#6333Uzlopak merged 4 commits intofastify:mainfrom
Uzlopak merged 4 commits intofastify:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the main fastify() factory function by extracting configuration processing logic into a dedicated processOptions function. This reduces the complexity of the main factory and clarifies the separation of concerns between option validation/normalization and Fastify instance creation.
Key Changes
- Extracted option processing logic into a new
processOptionsfunction - Moved server capability detection and connection management setup to the
createServerfunction - Reorganized helper functions and removed some inline definitions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| fastify.js | Main refactoring - extracted processOptions function and simplified main factory |
| lib/server.js | Added server capability detection logic and connection management setup |
| lib/route.js | Updated to get logger from options instead of fastifyArgs |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Uzlopak
reviewed
Sep 27, 2025
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.
Read #6329
A new
processOptionsfunction is now responsible for validating and normalizing options.This reduces noise in the
fastify()factory and clarifies responsibilities.Next steps
We can continue splitting complexity into focused modules.
Suggestions:
plugin-overrideandplugin-utilsinto a single module with a newinitAvviofunctionaddHookintohooks.jsChanges can be incremental.