aboutsummaryrefslogtreecommitdiffstats
path: root/backend/internal/router
diff options
context:
space:
mode:
Diffstat (limited to 'backend/internal/router')
-rw-r--r--backend/internal/router/router.go49
1 files changed, 42 insertions, 7 deletions
diff --git a/backend/internal/router/router.go b/backend/internal/router/router.go
index b82e1af..3a4d413 100644
--- a/backend/internal/router/router.go
+++ b/backend/internal/router/router.go
@@ -1,8 +1,7 @@
package router
import (
- "finance/backend/internal/api/auth"
- "finance/backend/internal/api/v1/users"
+ "finance/backend/internal/api/handlers"
"finance/backend/internal/config"
"finance/backend/internal/database"
"net/http"
@@ -66,21 +65,57 @@ func SetupRouter(cfg *config.Config) *gin.Engine {
})
})
+ // Initialize handlers
+ authHandler := handlers.NewAuthHandler(cfg)
+ goalHandler := handlers.NewGoalHandler()
+ userHandler := handlers.NewUserHandler()
+ accountHandler := handlers.NewAccountHandler()
+ transactionHandler := handlers.NewTransactionHandler()
+ loanHandler := handlers.NewLoanHandler()
+
// API v1 routes
v1 := r.Group("/api/v1")
{
// Auth routes (public)
- v1.POST("/auth/signup", auth.Signup(cfg))
- v1.POST("/auth/login", auth.Login(cfg))
+ v1.POST("/auth/signup", authHandler.Register)
+ v1.POST("/auth/login", authHandler.Login)
// Protected routes
protected := v1.Group("")
- protected.Use(auth.AuthMiddleware(cfg))
+ protected.Use(authHandler.JWTAuth)
{
// User routes
- protected.GET("/users/me", users.GetCurrentUser)
+ protected.GET("/users/me", userHandler.GetCurrentUser)
+ protected.PUT("/users/me", userHandler.UpdateCurrentUser)
+
+ // Account routes
+ protected.GET("/accounts", accountHandler.GetAccounts)
+ protected.GET("/accounts/:id", accountHandler.GetAccountByID)
+ protected.POST("/accounts", accountHandler.CreateAccount)
+ protected.PUT("/accounts/:id", accountHandler.UpdateAccount)
+ protected.DELETE("/accounts/:id", accountHandler.DeleteAccount)
+
+ // Transaction routes
+ protected.GET("/transactions", transactionHandler.GetTransactions)
+ protected.GET("/transactions/:id", transactionHandler.GetTransactionByID)
+ protected.POST("/transactions", transactionHandler.CreateTransaction)
+ protected.PUT("/transactions/:id", transactionHandler.UpdateTransaction)
+ protected.DELETE("/transactions/:id", transactionHandler.DeleteTransaction)
+
+ // Goal routes
+ protected.GET("/goals", goalHandler.GetGoals)
+ protected.GET("/goals/:id", goalHandler.GetGoal)
+ protected.POST("/goals", goalHandler.CreateGoal)
+ protected.PUT("/goals/:id", goalHandler.UpdateGoal)
+ protected.DELETE("/goals/:id", goalHandler.DeleteGoal)
+ protected.PATCH("/goals/:id/progress", goalHandler.UpdateGoalProgress)
- // Add other protected routes here
+ // Loan routes
+ protected.GET("/loans", loanHandler.GetLoans)
+ protected.GET("/loans/:id", loanHandler.GetLoanByID)
+ protected.POST("/loans", loanHandler.CreateLoan)
+ protected.PUT("/loans/:id", loanHandler.UpdateLoan)
+ protected.DELETE("/loans/:id", loanHandler.DeleteLoan)
}
}