Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the application from a Singleton pattern to Dependency Injection (DI) pattern, improving testability and architectural clarity. The monolithic AppState singleton is replaced with two focused components: Config for immutable configuration and DomainStore for thread-safe domain data management.
Key changes include:
- Introduction of
DomainStorewith mutex-protected concurrent access to domain data - Separation of configuration into an immutable
Configstruct - Refactoring of all utility and provider functions to accept dependencies as parameters instead of accessing global state
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/state/DomainStore.go | New thread-safe store for domain data with RWMutex protection |
| internal/state/Config.go | New immutable configuration struct for application settings |
| internal/state/AppState.go | Deleted singleton pattern implementation |
| internal/app/app.go | New application bootstrap that wires dependencies together |
| internal/utils/whois.go | Refactored to use DomainStore dependency instead of AppState |
| internal/utils/notifications.go | Updated to accept both store and config as parameters |
| internal/utils/env_import.go | Renamed to LoadConfig and returns initialized dependencies |
| internal/utils/cli_report.go | Updated to use DomainStore dependency |
| internal/utils/providers/telegram.go | Refactored to use Config instead of AppState |
| internal/utils/providers/discord.go | Refactored to use Config instead of AppState |
| internal/utils/providers/ntfy.go | Refactored to use Config instead of AppState |
| internal/api/routes.go | Updated to use factory pattern for handler with DomainStore |
| internal/cron/cron.go | Updated to accept store and config as parameters |
| cmd/expira/main.go | Simplified to delegate initialization to app package |
Comments suppressed due to low confidence (1)
internal/utils/providers/discord.go:33
- The HTTP response status code is not checked. The Discord API may return a non-success status code (e.g., 4xx or 5xx) even if the HTTP request itself succeeds. Consider checking resp.StatusCode and returning an error if it's not in the 2xx range to properly handle API errors.
resp, err := http.Post(config.DiscordWebhookURL, "application/json", bytes.NewBuffer(data))
if err != nil {
return err
}
defer resp.Body.Close()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Dec 21, 2025
Closed
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.
No description provided.