From f250082fff0e690ee41b6865fa043dded5ac7218 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Mon, 9 Dec 2024 18:34:38 -0500 Subject: [PATCH] refactor: move gateway package to app directory --- {pkg => app}/gateway/config/Env.pkl.go | 0 {pkg => app}/gateway/config/env.go | 0 {pkg => app}/gateway/config/init.pkl.go | 0 {pkg => app}/gateway/config/internal/index.html | 0 {pkg => app}/gateway/config/internal/main.js | 0 {pkg => app}/gateway/config/internal/static.go | 0 {pkg => app}/gateway/config/internal/sw.js | 0 {pkg => app}/gateway/config/manifest.go | 0 {pkg => app}/gateway/config/schema.go | 0 {pkg => app}/gateway/config/vault.go | 2 +- {pkg => app}/gateway/handlers/index_handler.go | 4 ++-- {pkg => app}/gateway/handlers/login_handler.go | 0 {pkg => app}/gateway/handlers/register_handler.go | 4 ++-- {pkg => app}/gateway/handlers/spawn_handler.go | 0 {pkg => app}/gateway/internal/database/models.go | 0 {pkg => app}/gateway/internal/database/sqlite.go | 8 ++++---- .../gateway/internal}/pages/index/error.templ | 0 .../gateway/internal}/pages/index/error_templ.go | 0 .../gateway/internal}/pages/index/page.templ | 0 .../gateway/internal}/pages/index/page_templ.go | 0 .../gateway => app/gateway/internal}/pages/login/model.go | 0 .../gateway/internal}/pages/register/model.go | 0 .../gateway/internal}/pages/register/page.templ | 0 .../gateway/internal}/pages/register/page_templ.go | 0 {pkg => app}/gateway/internal/session/context.go | 2 +- {pkg => app}/gateway/internal/session/db.go | 0 {pkg => app}/gateway/internal/session/middleware.go | 4 ++-- {pkg => app}/gateway/internal/session/session.go | 2 +- {pkg => app}/gateway/routes.go | 0 {pkg => app}/gateway/types/Config.pkl.go | 0 {pkg => app}/gateway/types/Ctx.pkl.go | 0 {pkg => app}/gateway/types/init.pkl.go | 0 32 files changed, 13 insertions(+), 13 deletions(-) rename {pkg => app}/gateway/config/Env.pkl.go (100%) rename {pkg => app}/gateway/config/env.go (100%) rename {pkg => app}/gateway/config/init.pkl.go (100%) rename {pkg => app}/gateway/config/internal/index.html (100%) rename {pkg => app}/gateway/config/internal/main.js (100%) rename {pkg => app}/gateway/config/internal/static.go (100%) rename {pkg => app}/gateway/config/internal/sw.js (100%) rename {pkg => app}/gateway/config/manifest.go (100%) rename {pkg => app}/gateway/config/schema.go (100%) rename {pkg => app}/gateway/config/vault.go (96%) rename {pkg => app}/gateway/handlers/index_handler.go (92%) rename {pkg => app}/gateway/handlers/login_handler.go (100%) rename {pkg => app}/gateway/handlers/register_handler.go (96%) rename {pkg => app}/gateway/handlers/spawn_handler.go (100%) rename {pkg => app}/gateway/internal/database/models.go (100%) rename {pkg => app}/gateway/internal/database/sqlite.go (88%) rename {pkg/gateway => app/gateway/internal}/pages/index/error.templ (100%) rename {pkg/gateway => app/gateway/internal}/pages/index/error_templ.go (100%) rename {pkg/gateway => app/gateway/internal}/pages/index/page.templ (100%) rename {pkg/gateway => app/gateway/internal}/pages/index/page_templ.go (100%) rename {pkg/gateway => app/gateway/internal}/pages/login/model.go (100%) rename {pkg/gateway => app/gateway/internal}/pages/register/model.go (100%) rename {pkg/gateway => app/gateway/internal}/pages/register/page.templ (100%) rename {pkg/gateway => app/gateway/internal}/pages/register/page_templ.go (100%) rename {pkg => app}/gateway/internal/session/context.go (97%) rename {pkg => app}/gateway/internal/session/db.go (100%) rename {pkg => app}/gateway/internal/session/middleware.go (91%) rename {pkg => app}/gateway/internal/session/session.go (98%) rename {pkg => app}/gateway/routes.go (100%) rename {pkg => app}/gateway/types/Config.pkl.go (100%) rename {pkg => app}/gateway/types/Ctx.pkl.go (100%) rename {pkg => app}/gateway/types/init.pkl.go (100%) diff --git a/pkg/gateway/config/Env.pkl.go b/app/gateway/config/Env.pkl.go similarity index 100% rename from pkg/gateway/config/Env.pkl.go rename to app/gateway/config/Env.pkl.go diff --git a/pkg/gateway/config/env.go b/app/gateway/config/env.go similarity index 100% rename from pkg/gateway/config/env.go rename to app/gateway/config/env.go diff --git a/pkg/gateway/config/init.pkl.go b/app/gateway/config/init.pkl.go similarity index 100% rename from pkg/gateway/config/init.pkl.go rename to app/gateway/config/init.pkl.go diff --git a/pkg/gateway/config/internal/index.html b/app/gateway/config/internal/index.html similarity index 100% rename from pkg/gateway/config/internal/index.html rename to app/gateway/config/internal/index.html diff --git a/pkg/gateway/config/internal/main.js b/app/gateway/config/internal/main.js similarity index 100% rename from pkg/gateway/config/internal/main.js rename to app/gateway/config/internal/main.js diff --git a/pkg/gateway/config/internal/static.go b/app/gateway/config/internal/static.go similarity index 100% rename from pkg/gateway/config/internal/static.go rename to app/gateway/config/internal/static.go diff --git a/pkg/gateway/config/internal/sw.js b/app/gateway/config/internal/sw.js similarity index 100% rename from pkg/gateway/config/internal/sw.js rename to app/gateway/config/internal/sw.js diff --git a/pkg/gateway/config/manifest.go b/app/gateway/config/manifest.go similarity index 100% rename from pkg/gateway/config/manifest.go rename to app/gateway/config/manifest.go diff --git a/pkg/gateway/config/schema.go b/app/gateway/config/schema.go similarity index 100% rename from pkg/gateway/config/schema.go rename to app/gateway/config/schema.go diff --git a/pkg/gateway/config/vault.go b/app/gateway/config/vault.go similarity index 96% rename from pkg/gateway/config/vault.go rename to app/gateway/config/vault.go index ff564abcc..9fb5861c1 100644 --- a/pkg/gateway/config/vault.go +++ b/app/gateway/config/vault.go @@ -4,7 +4,7 @@ import ( "encoding/json" "github.com/ipfs/boxo/files" - "github.com/onsonr/sonr/pkg/gateway/config/internal" + "github.com/onsonr/sonr/app/gateway/config/internal" "github.com/onsonr/sonr/pkg/vault/types" ) diff --git a/pkg/gateway/handlers/index_handler.go b/app/gateway/handlers/index_handler.go similarity index 92% rename from pkg/gateway/handlers/index_handler.go rename to app/gateway/handlers/index_handler.go index 93b3dd002..44aaf500d 100644 --- a/pkg/gateway/handlers/index_handler.go +++ b/app/gateway/handlers/index_handler.go @@ -2,9 +2,9 @@ package handlers import ( "github.com/labstack/echo/v4" + "github.com/onsonr/sonr/app/gateway/internal/pages/index" + "github.com/onsonr/sonr/app/gateway/internal/session" "github.com/onsonr/sonr/pkg/common/response" - "github.com/onsonr/sonr/pkg/gateway/internal/session" - "github.com/onsonr/sonr/pkg/gateway/pages/index" ) func HandleIndex(c echo.Context) error { diff --git a/pkg/gateway/handlers/login_handler.go b/app/gateway/handlers/login_handler.go similarity index 100% rename from pkg/gateway/handlers/login_handler.go rename to app/gateway/handlers/login_handler.go diff --git a/pkg/gateway/handlers/register_handler.go b/app/gateway/handlers/register_handler.go similarity index 96% rename from pkg/gateway/handlers/register_handler.go rename to app/gateway/handlers/register_handler.go index 5b63d0807..f1706a8cb 100644 --- a/pkg/gateway/handlers/register_handler.go +++ b/app/gateway/handlers/register_handler.go @@ -8,11 +8,11 @@ import ( "github.com/go-webauthn/webauthn/protocol" "github.com/labstack/echo/v4" + "github.com/onsonr/sonr/app/gateway/internal/database" + "github.com/onsonr/sonr/app/gateway/internal/pages/register" "github.com/onsonr/sonr/crypto/mpc" "github.com/onsonr/sonr/pkg/common/response" "github.com/onsonr/sonr/pkg/common/styles/forms" - "github.com/onsonr/sonr/pkg/gateway/internal/database" - "github.com/onsonr/sonr/pkg/gateway/pages/register" ) func HandleRegisterView(c echo.Context) error { diff --git a/pkg/gateway/handlers/spawn_handler.go b/app/gateway/handlers/spawn_handler.go similarity index 100% rename from pkg/gateway/handlers/spawn_handler.go rename to app/gateway/handlers/spawn_handler.go diff --git a/pkg/gateway/internal/database/models.go b/app/gateway/internal/database/models.go similarity index 100% rename from pkg/gateway/internal/database/models.go rename to app/gateway/internal/database/models.go diff --git a/pkg/gateway/internal/database/sqlite.go b/app/gateway/internal/database/sqlite.go similarity index 88% rename from pkg/gateway/internal/database/sqlite.go rename to app/gateway/internal/database/sqlite.go index 133bf844a..f1dabdb6e 100644 --- a/pkg/gateway/internal/database/sqlite.go +++ b/app/gateway/internal/database/sqlite.go @@ -4,7 +4,7 @@ import ( "os" "path/filepath" - "github.com/onsonr/sonr/pkg/gateway/config" + "github.com/onsonr/sonr/app/gateway/config" "gorm.io/driver/sqlite" "gorm.io/gorm" ) @@ -32,12 +32,12 @@ func formatDBPath(path string) string { if home == "" { home = "." } - + configDir := filepath.Join(home, ".config", "hway") - if err := os.MkdirAll(configDir, 0755); err != nil { + if err := os.MkdirAll(configDir, 0o755); err != nil { // If we can't create the directory, fall back to current directory return path } - + return filepath.Join(configDir, path) } diff --git a/pkg/gateway/pages/index/error.templ b/app/gateway/internal/pages/index/error.templ similarity index 100% rename from pkg/gateway/pages/index/error.templ rename to app/gateway/internal/pages/index/error.templ diff --git a/pkg/gateway/pages/index/error_templ.go b/app/gateway/internal/pages/index/error_templ.go similarity index 100% rename from pkg/gateway/pages/index/error_templ.go rename to app/gateway/internal/pages/index/error_templ.go diff --git a/pkg/gateway/pages/index/page.templ b/app/gateway/internal/pages/index/page.templ similarity index 100% rename from pkg/gateway/pages/index/page.templ rename to app/gateway/internal/pages/index/page.templ diff --git a/pkg/gateway/pages/index/page_templ.go b/app/gateway/internal/pages/index/page_templ.go similarity index 100% rename from pkg/gateway/pages/index/page_templ.go rename to app/gateway/internal/pages/index/page_templ.go diff --git a/pkg/gateway/pages/login/model.go b/app/gateway/internal/pages/login/model.go similarity index 100% rename from pkg/gateway/pages/login/model.go rename to app/gateway/internal/pages/login/model.go diff --git a/pkg/gateway/pages/register/model.go b/app/gateway/internal/pages/register/model.go similarity index 100% rename from pkg/gateway/pages/register/model.go rename to app/gateway/internal/pages/register/model.go diff --git a/pkg/gateway/pages/register/page.templ b/app/gateway/internal/pages/register/page.templ similarity index 100% rename from pkg/gateway/pages/register/page.templ rename to app/gateway/internal/pages/register/page.templ diff --git a/pkg/gateway/pages/register/page_templ.go b/app/gateway/internal/pages/register/page_templ.go similarity index 100% rename from pkg/gateway/pages/register/page_templ.go rename to app/gateway/internal/pages/register/page_templ.go diff --git a/pkg/gateway/internal/session/context.go b/app/gateway/internal/session/context.go similarity index 97% rename from pkg/gateway/internal/session/context.go rename to app/gateway/internal/session/context.go index efcaf1b35..9014b846c 100644 --- a/pkg/gateway/internal/session/context.go +++ b/app/gateway/internal/session/context.go @@ -5,8 +5,8 @@ import ( "strings" "github.com/labstack/echo/v4" + "github.com/onsonr/sonr/app/gateway/internal/database" "github.com/onsonr/sonr/pkg/common" - "github.com/onsonr/sonr/pkg/gateway/internal/database" "github.com/segmentio/ksuid" ) diff --git a/pkg/gateway/internal/session/db.go b/app/gateway/internal/session/db.go similarity index 100% rename from pkg/gateway/internal/session/db.go rename to app/gateway/internal/session/db.go diff --git a/pkg/gateway/internal/session/middleware.go b/app/gateway/internal/session/middleware.go similarity index 91% rename from pkg/gateway/internal/session/middleware.go rename to app/gateway/internal/session/middleware.go index d52fa2288..d9f37fd74 100644 --- a/pkg/gateway/internal/session/middleware.go +++ b/app/gateway/internal/session/middleware.go @@ -4,8 +4,8 @@ import ( "net/http" "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/pkg/gateway/config" - "github.com/onsonr/sonr/pkg/gateway/internal/database" + "github.com/onsonr/sonr/app/gateway/config" + "github.com/onsonr/sonr/app/gateway/internal/database" "gorm.io/gorm" ) diff --git a/pkg/gateway/internal/session/session.go b/app/gateway/internal/session/session.go similarity index 98% rename from pkg/gateway/internal/session/session.go rename to app/gateway/internal/session/session.go index 98f292b0f..cf2718f95 100644 --- a/pkg/gateway/internal/session/session.go +++ b/app/gateway/internal/session/session.go @@ -2,7 +2,7 @@ package session import ( "github.com/labstack/echo/v4" - "github.com/onsonr/sonr/pkg/gateway/internal/database" + "github.com/onsonr/sonr/app/gateway/internal/database" ) // ╭───────────────────────────────────────────────────────╮ diff --git a/pkg/gateway/routes.go b/app/gateway/routes.go similarity index 100% rename from pkg/gateway/routes.go rename to app/gateway/routes.go diff --git a/pkg/gateway/types/Config.pkl.go b/app/gateway/types/Config.pkl.go similarity index 100% rename from pkg/gateway/types/Config.pkl.go rename to app/gateway/types/Config.pkl.go diff --git a/pkg/gateway/types/Ctx.pkl.go b/app/gateway/types/Ctx.pkl.go similarity index 100% rename from pkg/gateway/types/Ctx.pkl.go rename to app/gateway/types/Ctx.pkl.go diff --git a/pkg/gateway/types/init.pkl.go b/app/gateway/types/init.pkl.go similarity index 100% rename from pkg/gateway/types/init.pkl.go rename to app/gateway/types/init.pkl.go