refactor: move gateway and vault packages to internal directory

This commit is contained in:
Prad Nukala
2024-12-10 12:52:19 -05:00
parent b81bdebd64
commit dc6f02a000
73 changed files with 58 additions and 59 deletions
+32
View File
@@ -0,0 +1,32 @@
// Package gateway provides the default routes for the Sonr hway.
package gateway
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/internal/gateway/config"
"github.com/onsonr/sonr/internal/gateway/database"
"github.com/onsonr/sonr/internal/gateway/handlers"
"github.com/onsonr/sonr/internal/gateway/session"
"github.com/onsonr/sonr/pkg/common/response"
)
func RegisterRoutes(e *echo.Echo, env config.Env) error {
// Custom error handler for gateway
e.HTTPErrorHandler = response.RedirectOnError("http://localhost:3000")
// Initialize database
db, err := database.InitDB(env)
if err != nil {
return err
}
// Inject session middleware with database connection
e.Use(session.Middleware(db, env))
// Register routes
e.GET("/", handlers.HandleIndex)
e.GET("/register", handlers.HandleRegisterView)
e.POST("/register/start", handlers.HandleRegisterStart)
e.POST("/register/finish", handlers.HandleRegisterFinish)
return nil
}