Skip to content

refactor: delegate options processing to a dedicated function#6333

Merged
Uzlopak merged 4 commits intofastify:mainfrom
jean-michelet:refactor/factory-configuration
Sep 27, 2025
Merged

refactor: delegate options processing to a dedicated function#6333
Uzlopak merged 4 commits intofastify:mainfrom
jean-michelet:refactor/factory-configuration

Conversation

@jean-michelet
Copy link
Member

Read #6329

A new processOptions function 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:

  • Plugins: merge plugin-override and plugin-utils into a single module with a new initAvvio function
  • Inject: move into its own file
  • Hooks: move addHook into hooks.js
  • etc.

Changes can be incremental.

@Uzlopak Uzlopak requested a review from Copilot September 25, 2025 17:21
Copy link
Contributor

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 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 processOptions function
  • Moved server capability detection and connection management setup to the createServer function
  • 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.

@jean-michelet jean-michelet changed the title refactor: delegate configuration to builder a function refactor: delegate options processing to a dedicated function Sep 25, 2025
Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

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

LGTM

@jean-michelet jean-michelet requested a review from a team September 26, 2025 16:16
Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

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

LGTM

@Uzlopak Uzlopak merged commit a38ebb4 into fastify:main Sep 27, 2025
30 checks passed
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.

3 participants