cpularp-manager-api/src/gin-cpularp.go

36 lines
1.1 KiB
Go
Raw Normal View History

2025-04-24 13:58:05 -05:00
package main
import (
api "example.com/api"
authdiscord "example.com/auth/discord"
2025-04-29 00:42:57 -05:00
database "example.com/database"
2025-04-24 13:58:05 -05:00
"github.com/gin-gonic/gin"
)
func main() {
2025-04-29 00:42:57 -05:00
api.GlobalDatabase = database.InitializeDatabase()
api.GlobalConfig.ParseConfig("../config.toml")
2025-04-24 13:58:05 -05:00
api.GlobalOAuth = authdiscord.CreateDiscordOAuthConfig(api.GlobalConfig)
router := gin.Default()
2025-04-24 17:08:09 -05:00
// Authentication Workflow
router.GET("/auth/callback", api.AuthCallback)
router.GET("/auth/login", api.AuthLoginRedirect)
router.GET("/auth/logout", api.AuthLogoutRedirect)
// Create
router.POST("/user/update", api.CreateOrUpdateUser)
router.POST("/group", api.CreateGroup)
router.POST("/function", api.CreateFunction)
router.POST("/function-tag", api.CreateFunctionTag)
// Update
router.PUT("/function", api.UpdateFunction)
2025-04-24 17:08:09 -05:00
// Read
router.GET("/user/info", api.GetDiscordUser)
router.GET("/user/authorized", api.GetUserLoggedIn)
router.GET("/:object", api.GetObjects)
router.GET("/all/:object", api.GetAllObjects)
2025-04-24 17:08:09 -05:00
// Delete
router.DELETE("/function", api.DeleteFunction)
router.Run(":31337")
2025-04-24 13:58:05 -05:00
}