2025-04-24 13:58:05 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
api "example.com/api"
|
|
|
|
authdiscord "example.com/auth/discord"
|
|
|
|
configserver "example.com/config/server"
|
|
|
|
databasecommands "example.com/database/commands"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
api.GlobalDatabase = databasecommands.InitializeDatabase()
|
|
|
|
api.GlobalConfig = configserver.ParseConfig("../config.toml")
|
|
|
|
api.GlobalOAuth = authdiscord.CreateDiscordOAuthConfig(api.GlobalConfig)
|
|
|
|
app := gin.Default()
|
2025-04-24 17:08:09 -05:00
|
|
|
// Authentication Workflow
|
2025-04-24 13:58:05 -05:00
|
|
|
app.GET("/auth/callback", api.AuthCallback)
|
2025-04-24 17:08:09 -05:00
|
|
|
app.GET("/auth/login", api.AuthLoginRedirect)
|
|
|
|
app.GET("/auth/logout", api.AuthLogoutRedirect)
|
|
|
|
// Create & Update
|
|
|
|
app.POST("/post/user/update", api.CreateOrUpdateUser)
|
2025-04-25 00:25:58 -05:00
|
|
|
app.POST("/post/group", api.CreateDatabaseGroup)
|
2025-04-25 17:39:40 -05:00
|
|
|
app.POST("/post/function", api.CreateDatabaseFunction)
|
|
|
|
app.POST("/post/function-tag", api.CreateDatabaseFunctionTag)
|
2025-04-24 17:08:09 -05:00
|
|
|
// Read
|
|
|
|
app.GET("/get/user/info", api.GetUserInfo)
|
|
|
|
app.GET("/get/user/authorized", api.GetIsUserAuthorized)
|
2025-04-24 20:17:30 -05:00
|
|
|
app.GET("/get/group", api.GetDatabaseGroup)
|
|
|
|
app.GET("/get/groups", api.GetDatabaseGroups)
|
2025-04-25 17:39:40 -05:00
|
|
|
app.GET("/get/function", api.GetDatabaseFunction)
|
|
|
|
app.GET("/get/functions", api.GetDatabaseFunctions)
|
|
|
|
app.GET("/get/function-tag", api.GetDatabaseFunctionTag)
|
|
|
|
app.GET("/get/function-tags", api.GetDatabaseFunctionTags)
|
2025-04-24 17:08:09 -05:00
|
|
|
// Delete
|
2025-04-24 13:58:05 -05:00
|
|
|
app.Run(":31337")
|
|
|
|
}
|