-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
accd5c2
commit 044ea2a
Showing
22 changed files
with
256 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package errors | ||
|
||
import "github.com/gofiber/fiber/v2" | ||
|
||
var ( | ||
PassedAuthenticateMiddlewareButNilClaims = Error{ | ||
StatusCode: fiber.StatusInternalServerError, | ||
Message: "passed authenticate middleware but claims is nil", | ||
} | ||
FailedToCastToCustomClaims = Error{ | ||
StatusCode: fiber.StatusInternalServerError, | ||
Message: "failed to cast to custom claims", | ||
} | ||
ExpectedClaimsButGotNil = Error{ | ||
StatusCode: fiber.StatusInternalServerError, | ||
Message: "expected claims but got nil", | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/config" | ||
"github.com/GenerateNU/sac/backend/src/controllers" | ||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
func Auth(router fiber.Router, authService services.AuthServiceInterface, authSettings config.AuthSettings) { | ||
authController := controllers.NewAuthController(authService, authSettings) | ||
|
||
// api/v1/auth/* | ||
auth := router.Group("/auth") | ||
|
||
auth.Post("/login", authController.Login) | ||
auth.Get("/logout", authController.Logout) | ||
auth.Get("/refresh", authController.Refresh) | ||
auth.Get("/me", authController.Me) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/controllers" | ||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
func Category(router fiber.Router, categoryService services.CategoryServiceInterface) fiber.Router { | ||
categoryController := controllers.NewCategoryController(categoryService) | ||
|
||
categories := router.Group("/categories") | ||
|
||
categories.Post("/", categoryController.CreateCategory) | ||
categories.Get("/", categoryController.GetCategories) | ||
categories.Get("/:id", categoryController.GetCategory) | ||
categories.Delete("/:id", categoryController.DeleteCategory) | ||
categories.Patch("/:id", categoryController.UpdateCategory) | ||
|
||
return categories | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/controllers" | ||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
func CategoryTag(router fiber.Router, categoryTagService services.CategoryTagServiceInterface) { | ||
categoryTagController := controllers.NewCategoryTagController(categoryTagService) | ||
|
||
categoryTags := router.Group("/:categoryID/tags") | ||
|
||
categoryTags.Get("/", categoryTagController.GetTagsByCategory) | ||
categoryTags.Get("/:tagID", categoryTagController.GetTagByCategory) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/controllers" | ||
"github.com/GenerateNU/sac/backend/src/middleware" | ||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/GenerateNU/sac/backend/src/types" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
func Club(router fiber.Router, clubService services.ClubServiceInterface, middlewareService middleware.MiddlewareInterface) { | ||
clubController := controllers.NewClubController(clubService) | ||
|
||
clubs := router.Group("/clubs") | ||
|
||
clubs.Get("/", middlewareService.Authorize(types.ClubReadAll), clubController.GetAllClubs) | ||
clubs.Post("/", clubController.CreateClub) | ||
|
||
// api/v1/clubs/:id/* | ||
clubsID := clubs.Group("/:id") | ||
clubsID.Use(middleware.SuperSkipper(middlewareService.UserAuthorizeById)) | ||
|
||
clubsID.Get("/", clubController.GetClub) | ||
clubsID.Patch("/", middlewareService.Authorize(types.ClubWrite), clubController.UpdateClub) | ||
clubsID.Delete("/", middleware.SuperSkipper(middlewareService.Authorize(types.ClubDelete)), clubController.DeleteClub) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/controllers" | ||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
func Tag(router fiber.Router, tagService services.TagServiceInterface) { | ||
tagController := controllers.NewTagController(tagService) | ||
|
||
tags := router.Group("/tags") | ||
|
||
tags.Get("/:tagID", tagController.GetTag) | ||
tags.Post("/", tagController.CreateTag) | ||
tags.Patch("/:tagID", tagController.UpdateTag) | ||
tags.Delete("/:tagID", tagController.DeleteTag) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/controllers" | ||
"github.com/GenerateNU/sac/backend/src/middleware" | ||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/GenerateNU/sac/backend/src/types" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
func User(router fiber.Router, userService services.UserServiceInterface, middlewareService middleware.MiddlewareInterface) fiber.Router { | ||
userController := controllers.NewUserController(userService) | ||
|
||
// api/v1/users/* | ||
users := router.Group("/users") | ||
users.Post("/", userController.CreateUser) | ||
users.Get("/", middleware.SuperSkipper(middlewareService.Authorize(types.UserReadAll)), userController.GetUsers) | ||
|
||
// api/v1/users/:userID/* | ||
usersID := users.Group("/:userID") | ||
usersID.Use(middleware.SuperSkipper(middlewareService.UserAuthorizeById)) | ||
|
||
usersID.Get("/", userController.GetUser) | ||
usersID.Patch("/", userController.UpdateUser) | ||
usersID.Delete("/", userController.DeleteUser) | ||
|
||
return users | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/controllers" | ||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
func UserTag(router fiber.Router, userTagService services.UserTagServiceInterface) { | ||
userTagController := controllers.NewUserTagController(userTagService) | ||
|
||
userTags := router.Group("/:userID/tags") | ||
|
||
userTags.Post("/", userTagController.CreateUserTags) | ||
userTags.Get("/", userTagController.GetUserTags) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/gofiber/fiber/v2" | ||
"github.com/gofiber/swagger" | ||
) | ||
|
||
func Utility(router fiber.Router) { | ||
router.Get("/swagger/*", swagger.HandlerDefault) | ||
router.Get("/health", func(c *fiber.Ctx) error { | ||
return c.SendStatus(200) | ||
}) | ||
} |
Oops, something went wrong.