possibly first working draft
This commit is contained in:
42
cmd/main.go
42
cmd/main.go
@ -1,13 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"kadath.corp/git/adminoo/donniemarko/web"
|
||||
|
||||
"kadath.corp/git/adminoo/donniemarko/models"
|
||||
"donniemarko/internal/render"
|
||||
"donniemarko/internal/scanner"
|
||||
"donniemarko/internal/service"
|
||||
"donniemarko/internal/storage"
|
||||
"donniemarko/internal/web"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -23,15 +26,34 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
// Initialize the directory manager
|
||||
dm := models.NewTree(*rootFolder)
|
||||
go dm.MonitorFileChange()
|
||||
// Initialize storage
|
||||
noteStorage := storage.NewNoteStorage()
|
||||
|
||||
tm := web.NewTemplateManager("web/templates")
|
||||
// Initialize scanner
|
||||
monitor := scanner.NewScanner(*rootFolder)
|
||||
|
||||
rh := web.NewRouteHandler(dm, tm)
|
||||
rh.SetupRoutes()
|
||||
// Initialize notes handler for scanner
|
||||
notesHandler := scanner.NewNotesHandler(noteStorage)
|
||||
monitor.SetHandler(notesHandler)
|
||||
|
||||
// Initialize service
|
||||
noteService := service.NewNoteService()
|
||||
noteService.SetStorage(noteStorage)
|
||||
|
||||
// Start scanner in background
|
||||
ctx := context.Background()
|
||||
go monitor.Monitor(ctx)
|
||||
|
||||
// log.Println("WE GET THERE", len(noteStorage.Index))
|
||||
// Initialize template manager
|
||||
tm := render.NewTemplateManager("internal/web/templates")
|
||||
|
||||
// Initialize web handler
|
||||
handler := web.NewHandler(noteService, tm)
|
||||
|
||||
// Setup routes
|
||||
handler.SetupRoutes()
|
||||
|
||||
log.Printf("Serving on http://%s", *listenAddr)
|
||||
http.ListenAndServe(*listenAddr, nil)
|
||||
log.Fatal(http.ListenAndServe(*listenAddr, nil))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user