From 453e9805ef6583e2177fb55fa1e45cf5816a7e67 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Sun, 21 Dec 2025 19:01:42 +0100 Subject: feat(backend): connect to sqlite db --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 480762d..6b5571e 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "os/signal" "strconv" "syscall" + "time" "git.anhgelus.world/anhgelus/small-web/backend" "github.com/joho/godotenv" @@ -58,6 +59,15 @@ func main() { os.Exit(1) } + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() + db := backend.ConnectDatabase(cfg) + defer db.Close() + err := backend.RunMigration(ctx, db) + if err != nil { + panic(err) + } + for _, sec := range cfg.Sections { if ok = sec.Load(cfg); !ok { slog.Info("exiting") -- cgit v1.2.3 From 322826d06e425297fcbbc976a0566868a74f2d87 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Sun, 21 Dec 2025 22:16:52 +0100 Subject: feat(backend): record every jump between pages --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index 6b5571e..3ffe37a 100644 --- a/main.go +++ b/main.go @@ -80,7 +80,7 @@ func main() { assetsFS = os.DirFS("dist") } - r := backend.NewRouter(dev, cfg, assetsFS) + r := backend.NewRouter(dev, cfg, db, assetsFS) backend.HandleHome(r) backend.HandleRoot(r, cfg) -- cgit v1.2.3 From 84af6427d8205b1882b9f9df11ce394f96d6b792 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Mon, 22 Dec 2025 15:07:55 +0100 Subject: feat(backend): admin dashboard --- main.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 3ffe37a..4f2fd6b 100644 --- a/main.go +++ b/main.go @@ -89,6 +89,8 @@ func main() { } backend.Handle404(r) + backend.HandleAdmin(r) + backend.HandleStaticFiles(r, "/assets", assetsFS) backend.HandleStaticFiles(r, "/static", os.DirFS(cfg.PublicFolder)) -- cgit v1.2.3 From cbd5c09c5e1403709d4aabf91051443f147689e5 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Mon, 22 Dec 2025 18:34:02 +0100 Subject: refactor(backend): move db related in new package --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 4f2fd6b..b1a192e 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( "time" "git.anhgelus.world/anhgelus/small-web/backend" + "git.anhgelus.world/anhgelus/small-web/backend/storage" "github.com/joho/godotenv" ) @@ -61,9 +62,9 @@ func main() { ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() - db := backend.ConnectDatabase(cfg) + db := storage.ConnectDatabase(cfg.Database) defer db.Close() - err := backend.RunMigration(ctx, db) + err := storage.RunMigration(ctx, db) if err != nil { panic(err) } -- cgit v1.2.3