change to GORM, add member and rank handlers

This commit is contained in:
2024-03-08 00:39:46 -08:00
parent 84424fdae9
commit 3b715cf331
36 changed files with 3491 additions and 230 deletions

View File

@@ -1,9 +1,6 @@
package routes
import (
"gitea.iceberg-gaming.com/17th-Ranger-Battalion-ORG/17th-UnitTracker-API/db"
"gitea.iceberg-gaming.com/17th-Ranger-Battalion-ORG/17th-UnitTracker-API/ops"
"errors"
"strings"
@@ -19,22 +16,8 @@ func SetupRoutes(
cfg := viper.GetViper()
prefixURL := strings.TrimRight(cfg.GetString("API_PREFIX"), "/")
mainPrefix := e.Group(prefixURL, func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
// do something before the next handler
// ensure we always have a db connection
_, err := db.GetDB()
if err != nil {
return err
}
return next(c)
}
})
// MEMBER OPERATIONS
g := mainPrefix.Group("/members")
g.GET("", ops.GetMembers)
g.GET("/:id", ops.GetMember)
mainPrefix := e.Group(prefixURL)
setupMemberRoutes(e, mainPrefix)
setupRankRoutes(e, mainPrefix)
}