Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract Alerts configuration #1372

Merged
merged 3 commits into from
Apr 11, 2024
Merged

Extract Alerts configuration #1372

merged 3 commits into from
Apr 11, 2024

Conversation

fmrsabino
Copy link
Collaborator

@fmrsabino fmrsabino commented Apr 5, 2024

  • The Alerts related configuration and environment keys were extracted to the AlertsApiModule and AlertsControllerModule.
  • By separating the properties of the Alerts feature to its own configuration object which is loaded dynamically, we can make some properties set as required in the application only if the respective feature is loaded.
  • This effectively reduces the number of configuration properties that is needed to set for the application to launch, when features are under development or a set of features is not needed by the hosting party.
  • In order to avoid key collision, the feature level configuration now uses namespaces (with registerAs).
    • alerts-api for keys used in /datasources/alerts-api
    • alerts-route for keys used in /routes/alerts
classDiagram
    ConfigurationModule ..> rootConfiguration
    AlertsApiConfigurationModule ..> alertsApiConfiguration
    AlertsConfigurationModule ..> alertsConfiguration
    NestConfigService o-- ConfigurationModule
    NestConfigService o-- AlertsApiConfigurationModule
    NestConfigService o-- AlertsConfigurationModule
    IConfigurationService -- NestConfigService
    FeatureA ..|> IConfigurationService
    FeatureB ..|> IConfigurationService
    FeatureC ..|> IConfigurationService

    <<Interface>> IConfigurationService
    <<Service>> NestConfigService
    <<Module>> ConfigurationModule
    <<Module>> AlertsApiConfigurationModule
    <<Module>> AlertsConfigurationModule

    note for AlertsApiConfigurationModule "Only loaded if feature flag is set to true"
    note for AlertsConfigurationModule "Only loaded if feature flag is set to true"

    class IConfigurationService {
    }
    class NestConfigService {
    }
    class ConfigurationModule {
    }
    class rootConfiguration {
        about
        applicationPort
        ...
    }
    class AlertsApiConfigurationModule {
    }
    class alertsApiConfiguration {
        apiKey
        baseUri
        account
        project
    }
    class AlertsConfigurationModule {
    }
    class alertsConfiguration {
        signingKey
    }

@fmrsabino fmrsabino self-assigned this Apr 5, 2024
Base automatically changed from extract-validator-logic to main April 9, 2024 10:33
@fmrsabino fmrsabino force-pushed the alerts-config branch 4 times, most recently from c5ae271 to 9da9912 Compare April 9, 2024 16:20
@coveralls
Copy link

coveralls commented Apr 9, 2024

Pull Request Test Coverage Report for Build 8644648086

Details

  • 36 of 40 (90.0%) changed or added relevant lines in 10 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 92.88%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/datasources/alerts-api/configuration/alerts-api.configuration.ts 5 7 71.43%
src/routes/alerts/configuration/alerts.configuration.ts 5 7 71.43%
Files with Coverage Reduction New Missed Lines %
src/routes/transactions/entities/tests/human-description.builder.ts 1 90.0%
Totals Coverage Status
Change from base Build 8619148770: -0.01%
Covered Lines: 6727
Relevant Lines: 6986

💛 - Coveralls

- The Alerts related configuration and environment keys were extracted to the AlertsApiModule and AlertsControllerModule.
- These modules are dynamic so we should not load and validate the respective configuration if they are not supposed to be available in the dependency graph.
- In order to avoid key collision, the feature level configuration now uses namespaces (with `registerAs`).
@@ -171,7 +164,7 @@ export default (): ReturnType<typeof configuration> => ({
express: { jsonLimit: '1mb' },
features: {
richFragments: true,
email: true,
email: false,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was set to false because otherwise, every test would have to include the now optional Alerts configuration (resulting in more changes).

Since this feature is opt-in, each test should decide if it should include the feature or not.

@fmrsabino fmrsabino marked this pull request as ready for review April 10, 2024 09:48
@fmrsabino fmrsabino requested a review from a team as a code owner April 10, 2024 09:48
@fmrsabino fmrsabino requested a review from iamacook April 10, 2024 15:07
Copy link
Member

@hectorgomezv hectorgomezv left a comment

Choose a reason for hiding this comment

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

👏🏻

@fmrsabino fmrsabino merged commit 27dda89 into main Apr 11, 2024
16 checks passed
@fmrsabino fmrsabino deleted the alerts-config branch April 11, 2024 10:01
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.

None yet

4 participants