dendrite.nvim/cmd/main.go

38 lines
1.5 KiB
Go

package main
import (
"log/slog"
"os"
"github.com/KristianJBorgwarth/dendrite.daemon/core/handlers/completion"
"github.com/KristianJBorgwarth/dendrite.daemon/core/handlers/note"
"github.com/KristianJBorgwarth/dendrite.daemon/core/handlers/vault"
"github.com/KristianJBorgwarth/dendrite.daemon/core/logging"
"github.com/KristianJBorgwarth/dendrite.daemon/core/server"
"github.com/KristianJBorgwarth/dendrite.daemon/core/services"
"github.com/KristianJBorgwarth/dendrite.daemon/persistence"
"github.com/KristianJBorgwarth/dendrite.daemon/persistence/repositories"
_ "modernc.org/sqlite"
)
func main() {
logging.Init()
server := server.NewServer()
uow := repositories.NewUnitOfWork();
linkRepo := repositories.NewLinkRepository(*persistence.NewReadContext())
tagRepo := repositories.NewTagRepository()
noteRepo := repositories.NewNoteRepository(*persistence.NewReadContext())
tagService := services.NewTagService(tagRepo)
linkService := services.NewLinkService(linkRepo)
noteService := services.NewNoteService(tagRepo, linkRepo, noteRepo)
server.RegisterHandler("vault/init", vault.NewInitializeHandler())
server.RegisterHandler("note/create", note.NewCreateNoteHandler(uow, tagService, noteRepo))
server.RegisterHandler("note/save", note.NewSaveNoteHandler(uow, noteRepo, tagService, noteService, linkService))
server.RegisterHandler("completion/link", completion.NewCompleteLinkHandler(linkRepo))
if err := server.Run(os.Stdin, os.Stdout); err != nil {
slog.Error("server error", "error", err)
}
}