fix(main): di

This commit is contained in:
Kristian Borgwarth 2026-04-14 05:42:10 +02:00
parent 840460da57
commit 5456d4c291

View file

@ -10,6 +10,7 @@ import (
"github.com/KristianJBorgwarth/dendrite.daemon/core/logging" "github.com/KristianJBorgwarth/dendrite.daemon/core/logging"
"github.com/KristianJBorgwarth/dendrite.daemon/core/server" "github.com/KristianJBorgwarth/dendrite.daemon/core/server"
"github.com/KristianJBorgwarth/dendrite.daemon/core/services" "github.com/KristianJBorgwarth/dendrite.daemon/core/services"
"github.com/KristianJBorgwarth/dendrite.daemon/persistence"
"github.com/KristianJBorgwarth/dendrite.daemon/persistence/repositories" "github.com/KristianJBorgwarth/dendrite.daemon/persistence/repositories"
_ "modernc.org/sqlite" _ "modernc.org/sqlite"
) )
@ -19,7 +20,7 @@ func main() {
server := server.NewServer() server := server.NewServer()
uow := repositories.NewUnitOfWork(); uow := repositories.NewUnitOfWork();
linkRepo := repositories.NewLinkRepository() linkRepo := repositories.NewLinkRepository(*persistence.NewReadContext())
tagRepo := repositories.NewTagRepository() tagRepo := repositories.NewTagRepository()
noteRepo := repositories.NewNoteRepository() noteRepo := repositories.NewNoteRepository()
tagService := services.NewTagService(tagRepo) tagService := services.NewTagService(tagRepo)
@ -29,7 +30,7 @@ func main() {
server.RegisterHandler("vault/init", vault.NewInitializeHandler()) server.RegisterHandler("vault/init", vault.NewInitializeHandler())
server.RegisterHandler("note/create", note.NewCreateNoteHandler(uow, tagService, noteRepo)) server.RegisterHandler("note/create", note.NewCreateNoteHandler(uow, tagService, noteRepo))
server.RegisterHandler("note/save", note.NewSaveNoteHandler(uow, noteRepo, tagService, noteService, linkService)) server.RegisterHandler("note/save", note.NewSaveNoteHandler(uow, noteRepo, tagService, noteService, linkService))
server.RegisterHandler("completion/link", completion.NewCompleteLinkHandler()) server.RegisterHandler("completion/link", completion.NewCompleteLinkHandler(linkRepo))
if err := server.Run(os.Stdin, os.Stdout); err != nil { if err := server.Run(os.Stdin, os.Stdout); err != nil {
slog.Error("server error", "error", err) slog.Error("server error", "error", err)