mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 04:01:34 +00:00
This commit addresses a broken build state caused by a mid-stream architectural refactoring. The changes align the existing code with the new Domain-Driven Design (DDD-lite) structure outlined in `refactor.md`. Key changes include: - Defined missing domain interfaces for `Auth`, `Localization`, and `Search`. - Refactored application services to use a `Commands` and `Queries` pattern. - Updated GraphQL resolvers to call application services instead of accessing repositories directly. - Fixed dependency injection in `cmd/api/main.go` by removing the non-existent `ApplicationBuilder` and manually instantiating services. - Corrected numerous test files (`integration`, `unit`, and `repository` tests) to reflect the new architecture, including fixing mock objects and test suite setups. - Added missing database migrations for test schemas to resolve "no such table" errors. This effort successfully gets the application to a compilable state and passes a significant portion of the test suite, laying the groundwork for further development and fixing the remaining test failures.
71 lines
2.3 KiB
Go
71 lines
2.3 KiB
Go
package app
|
|
|
|
import (
|
|
"tercul/internal/app/analytics"
|
|
"tercul/internal/app/author"
|
|
"tercul/internal/app/bookmark"
|
|
"tercul/internal/app/category"
|
|
"tercul/internal/app/collection"
|
|
"tercul/internal/app/comment"
|
|
"tercul/internal/app/like"
|
|
"tercul/internal/app/localization"
|
|
"tercul/internal/app/tag"
|
|
"tercul/internal/app/translation"
|
|
"tercul/internal/app/user"
|
|
"tercul/internal/app/auth"
|
|
"tercul/internal/app/work"
|
|
"tercul/internal/data/sql"
|
|
"tercul/internal/domain/search"
|
|
platform_auth "tercul/internal/platform/auth"
|
|
)
|
|
|
|
// Application is a container for all the application-layer services.
|
|
type Application struct {
|
|
Author *author.Service
|
|
Bookmark *bookmark.Service
|
|
Category *category.Service
|
|
Collection *collection.Service
|
|
Comment *comment.Service
|
|
Like *like.Service
|
|
Tag *tag.Service
|
|
Translation *translation.Service
|
|
User *user.Service
|
|
Localization *localization.Service
|
|
Auth *auth.Service
|
|
Work *work.Service
|
|
Analytics analytics.Service
|
|
Repos *sql.Repositories
|
|
}
|
|
|
|
func NewApplication(repos *sql.Repositories, searchClient search.SearchClient, analyticsService analytics.Service) *Application {
|
|
jwtManager := platform_auth.NewJWTManager()
|
|
authorService := author.NewService(repos.Author)
|
|
bookmarkService := bookmark.NewService(repos.Bookmark)
|
|
categoryService := category.NewService(repos.Category)
|
|
collectionService := collection.NewService(repos.Collection)
|
|
commentService := comment.NewService(repos.Comment)
|
|
likeService := like.NewService(repos.Like)
|
|
tagService := tag.NewService(repos.Tag)
|
|
translationService := translation.NewService(repos.Translation)
|
|
userService := user.NewService(repos.User)
|
|
localizationService := localization.NewService(repos.Localization)
|
|
authService := auth.NewService(repos.User, jwtManager)
|
|
workService := work.NewService(repos.Work, searchClient)
|
|
|
|
return &Application{
|
|
Author: authorService,
|
|
Bookmark: bookmarkService,
|
|
Category: categoryService,
|
|
Collection: collectionService,
|
|
Comment: commentService,
|
|
Like: likeService,
|
|
Tag: tagService,
|
|
Translation: translationService,
|
|
User: userService,
|
|
Localization: localizationService,
|
|
Auth: authService,
|
|
Work: workService,
|
|
Analytics: analyticsService,
|
|
Repos: repos,
|
|
}
|
|
} |