diff --git a/apps/api-go/.air.linux.conf b/apps/api-go/.air.linux.conf new file mode 100644 index 00000000..2012299f --- /dev/null +++ b/apps/api-go/.air.linux.conf @@ -0,0 +1,47 @@ +# Config file for [Air](https://github.com/air-verse/air) in TOML format + +# Working directory +# . or absolute path, please note that the directories following must be under root. +root = "." +tmp_dir = "tmp" + +[build] +# Just plain old shell command. You could use `make` as well. +cmd = "go build -o ./application ./main.go" +# Binary file yields from `cmd`. +bin = "application" +# Customize binary. +full_bin = "./application" +# Watch these filename extensions. +include_ext = ["go", "tpl", "tmpl", "html", "mustache", "hbs", "pug"] +# Ignore these filename extensions or directories. +exclude_dir = ["tmp", "vendor", "node_modules"] +# Watch these directories if you specified. +include_dir = [] +# Exclude files. +exclude_file = [] +# This log file places in your tmp_dir. +log = "air.log" +# It's not necessary to trigger build each time file changes if it's too frequent. +delay = 1000 # ms +# Stop running old binary when build errors occur. +stop_on_error = true +# Send Interrupt signal before killing process (windows does not support this feature) +send_interrupt = false +# Delay after sending Interrupt signal +kill_delay = 500 # ms + +[log] +# Show log time +time = false + +[color] +# Customize each part's color. If no color found, use the raw app log. +main = "magenta" +watcher = "cyan" +build = "yellow" +runner = "green" + +[misc] +# Delete tmp directory on exit +clean_on_exit = true diff --git a/apps/api-go/.air.windows.conf b/apps/api-go/.air.windows.conf new file mode 100644 index 00000000..64a7150d --- /dev/null +++ b/apps/api-go/.air.windows.conf @@ -0,0 +1,47 @@ +# Config file for [Air](https://github.com/air-verse/air) in TOML format + +# Working directory +# . or absolute path, please note that the directories following must be under root. +root = "." +tmp_dir = "tmp" + +[build] +# Just plain old shell command. You could use `make` as well. +cmd = "go build -o ./application.exe ./main.go" +# Binary file yields from `cmd`. +bin = "application.exe" +# Customize binary. +full_bin = "application.exe" +# Watch these filename extensions. +include_ext = ["go", "tpl", "tmpl", "html", "mustache", "hbs", "pug"] +# Ignore these filename extensions or directories. +exclude_dir = ["tmp", "vendor", "node_modules"] +# Watch these directories if you specified. +include_dir = [] +# Exclude files. +exclude_file = [] +# This log file places in your tmp_dir. +log = "air.log" +# It's not necessary to trigger build each time file changes if it's too frequent. +delay = 1000 # ms +# Stop running old binary when build errors occur. +stop_on_error = true +# Send Interrupt signal before killing process (windows does not support this feature) +send_interrupt = false +# Delay after sending Interrupt signal +kill_delay = 500 # ms + +[log] +# Show log time +time = false + +[color] +# Customize each part's color. If no color found, use the raw app log. +main = "magenta" +watcher = "cyan" +build = "yellow" +runner = "green" + +[misc] +# Delete tmp directory on exit +clean_on_exit = true diff --git a/apps/api-go/.env.example b/apps/api-go/.env.example new file mode 100644 index 00000000..deabbd4e --- /dev/null +++ b/apps/api-go/.env.example @@ -0,0 +1,2 @@ +SERVER_URL="0.0.0.0:8080" +SERVER_READ_TIMEOUT=60 diff --git a/apps/api-go/.gitignore b/apps/api-go/.gitignore new file mode 100644 index 00000000..9cc7b435 --- /dev/null +++ b/apps/api-go/.gitignore @@ -0,0 +1,3 @@ +application +application.exe +/tmp diff --git a/apps/api-go/README.md b/apps/api-go/README.md new file mode 100644 index 00000000..a39baed9 --- /dev/null +++ b/apps/api-go/README.md @@ -0,0 +1 @@ +go install github.com/air-verse/air@latest diff --git a/apps/api-go/app/config.go b/apps/api-go/app/config.go new file mode 100644 index 00000000..df78c56d --- /dev/null +++ b/apps/api-go/app/config.go @@ -0,0 +1,21 @@ +package config + +import ( + "os" + "strconv" + "time" + + "github.com/gofiber/fiber/v2" +) + +// FiberConfig func for configuration Fiber app. +// See: https://docs.gofiber.io/api/fiber#config +func FiberConfig() fiber.Config { + // Define server settings. + readTimeoutSecondsCount, _ := strconv.Atoi(os.Getenv("SERVER_READ_TIMEOUT")) + + // Return Fiber configuration. + return fiber.Config{ + ReadTimeout: time.Second * time.Duration(readTimeoutSecondsCount), + } +} diff --git a/apps/api-go/app/controllers/ping.go b/apps/api-go/app/controllers/ping.go new file mode 100644 index 00000000..796559e4 --- /dev/null +++ b/apps/api-go/app/controllers/ping.go @@ -0,0 +1,19 @@ +package controllers + +import ( + "context" +) + +type PingOutput struct { + Body struct { + Message string `json:"message" doc:"Pong message"` + } +} + +func Ping(ctx context.Context, input *struct{}) (*PingOutput, error) { + + resp := &PingOutput{} + resp.Body.Message = "Pong!" + + return resp, nil +} diff --git a/apps/api-go/app/controllers/users.go b/apps/api-go/app/controllers/users.go new file mode 100644 index 00000000..424b7f21 --- /dev/null +++ b/apps/api-go/app/controllers/users.go @@ -0,0 +1,33 @@ +package controllers + +import ( + "context" +) + +type User struct { + ID int `json:"id" example:"1" doc:"Unique user ID"` + Name string `json:"name" example:"John Doe" doc:"User name"` + Email string `json:"email" example:"john@example.com" doc:"User email"` +} + +type GetUsersOutput struct { + Body struct { + Users []User `json:"users" doc:"List of users"` + Total int `json:"total" doc:"Total number of users"` + Message string `json:"message" doc:"Status message"` + } +} + +func GetUsers(ctx context.Context, input *struct{}) (*GetUsersOutput, error) { + users := []User{ + {ID: 1, Name: "John Doe", Email: "john@example.com"}, + {ID: 2, Name: "Jane Smith", Email: "jane@example.com"}, + } + + resp := &GetUsersOutput{} + resp.Body.Users = users + resp.Body.Total = len(users) + resp.Body.Message = "Users retrieved successfully" + + return resp, nil +} diff --git a/apps/api-go/app/middlewares/fiber.go b/apps/api-go/app/middlewares/fiber.go new file mode 100644 index 00000000..ae466d44 --- /dev/null +++ b/apps/api-go/app/middlewares/fiber.go @@ -0,0 +1,21 @@ +package fiber_middleware + +import ( + "time" + + "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/cors" + "github.com/gofiber/fiber/v2/middleware/limiter" + "github.com/gofiber/fiber/v2/middleware/logger" +) + +func FiberMiddleware(a *fiber.App) { + a.Use( + cors.New(), + logger.New(), + limiter.New(limiter.Config{ + Expiration: 60 * time.Second, + Max: 10, + }), + ) +} diff --git a/apps/api-go/app/models/users.go b/apps/api-go/app/models/users.go new file mode 100644 index 00000000..42593211 --- /dev/null +++ b/apps/api-go/app/models/users.go @@ -0,0 +1,20 @@ +package models + +import ( + "time" +) + +type User struct { + ID uint `gorm:"primaryKey;autoIncrement;comment:Unique identifier for the user" json:"id"` + Username string `gorm:"type:varchar(50);not null;uniqueIndex;comment:Unique username for application login" json:"username"` + BroadcasterType *string `gorm:"type:varchar(50);comment:Type of broadcaster (e.g., affiliate, partner, etc.)" json:"broadcaster_type"` + AvatarURL *string `gorm:"type:varchar(500);comment:URL to user's profile picture" json:"avatar_url"` + TwitchID *string `gorm:"type:varchar(100);uniqueIndex;comment:Twitch platform user identifier" json:"twitch_id"` + TwitchDisplayName *string `gorm:"type:varchar(100);comment:Display name shown on Twitch platform" json:"twitch_display_name"` + RiotID *string `gorm:"type:varchar(100);comment:Riot Games account identifier (username#tag format)" json:"riot_id"` + HdevAPIKey *string `gorm:"type:varchar(200);comment:Henrik Dev API key for VALORANT statistics access" json:"hdev_api_key"` + IsActive bool `gorm:"not null;default:true;comment:Account status flag - False for suspended/deleted accounts" json:"is_active"` + CreatedAt time.Time `gorm:"not null;autoCreateTime;comment:Account creation timestamp" json:"created_at"` + UpdatedAt time.Time `gorm:"not null;autoUpdateTime;comment:Last account modification timestamp" json:"updated_at"` + // Overlays []Overlay `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE;comment:User's overlay configurations for streaming" json:"overlays"` +} diff --git a/apps/api-go/app/routes/ping.go b/apps/api-go/app/routes/ping.go new file mode 100644 index 00000000..73ebd304 --- /dev/null +++ b/apps/api-go/app/routes/ping.go @@ -0,0 +1,11 @@ +package routes + +import ( + controllers "github.com/ValoryLabs/monorepo/app/controllers" + "github.com/danielgtaylor/huma/v2" + "github.com/gofiber/fiber/v2" +) + +func PingRoutes(app *fiber.App, api huma.API) { + huma.Get(api, "/ping", controllers.Ping) +} diff --git a/apps/api-go/app/routes/users.go b/apps/api-go/app/routes/users.go new file mode 100644 index 00000000..dab145cf --- /dev/null +++ b/apps/api-go/app/routes/users.go @@ -0,0 +1,12 @@ +package routes + +import ( + controllers "github.com/ValoryLabs/monorepo/app/controllers" + "github.com/danielgtaylor/huma/v2" + "github.com/gofiber/fiber/v2" +) + +func UsersRoutes(app *fiber.App, api huma.API) { + route := huma.NewGroup(api, "/users") + huma.Get(route, "/", controllers.GetUsers) +} diff --git a/apps/api-go/app/utils/start_server.go b/apps/api-go/app/utils/start_server.go new file mode 100644 index 00000000..281cc385 --- /dev/null +++ b/apps/api-go/app/utils/start_server.go @@ -0,0 +1,15 @@ +package utils + +import ( + "log" + "os" + + "github.com/gofiber/fiber/v2" +) + +func StartServer(a *fiber.App) { + // Run server. + if err := a.Listen(os.Getenv("SERVER_URL")); err != nil { + log.Printf("Oops... Server is not running! Reason: %v", err) + } +} diff --git a/apps/api-go/go.mod b/apps/api-go/go.mod new file mode 100644 index 00000000..ce7db340 --- /dev/null +++ b/apps/api-go/go.mod @@ -0,0 +1,35 @@ +module github.com/ValoryLabs/monorepo + +go 1.25.1 + +require ( + github.com/gofiber/fiber/v2 v2.52.9 + github.com/joho/godotenv v1.5.1 +) + +require ( + github.com/andybalholm/brotli v1.2.0 // indirect + github.com/danielgtaylor/huma/v2 v2.34.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect + github.com/jackc/pgx/v5 v5.7.6 // indirect + github.com/jackc/puddle/v2 v2.2.2 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/klauspost/compress v1.18.0 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/philhofer/fwd v1.2.0 // indirect + github.com/rivo/uniseg v0.4.7 // indirect + github.com/tinylib/msgp v1.4.0 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasthttp v1.66.0 // indirect + golang.org/x/crypto v0.42.0 // indirect + golang.org/x/sync v0.17.0 // indirect + golang.org/x/sys v0.36.0 // indirect + golang.org/x/text v0.29.0 // indirect + gorm.io/driver/postgres v1.6.0 // indirect + gorm.io/gorm v1.31.0 // indirect +) diff --git a/apps/api-go/go.sum b/apps/api-go/go.sum new file mode 100644 index 00000000..769d6d30 --- /dev/null +++ b/apps/api-go/go.sum @@ -0,0 +1,63 @@ +github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ= +github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= +github.com/danielgtaylor/huma/v2 v2.34.1 h1:EmOJAbzEGfy0wAq/QMQ1YKfEMBEfE94xdBRLPBP0gwQ= +github.com/danielgtaylor/huma/v2 v2.34.1/go.mod h1:ynwJgLk8iGVgoaipi5tgwIQ5yoFNmiu+QdhU7CEEmhk= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw= +github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk= +github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M= +github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= +github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= +github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM= +github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tinylib/msgp v1.4.0 h1:SYOeDRiydzOw9kSiwdYp9UcBgPFtLU2WDHaJXyHruf8= +github.com/tinylib/msgp v1.4.0/go.mod h1:cvjFkb4RiC8qSBOPMGPSzSAx47nAsfhLVTCZZNuHv5o= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.66.0 h1:M87A0Z7EayeyNaV6pfO3tUTUiYO0dZfEJnRGXTVNuyU= +github.com/valyala/fasthttp v1.66.0/go.mod h1:Y4eC+zwoocmXSVCB1JmhNbYtS7tZPRI2ztPB72EVObs= +github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= +github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= +golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI= +golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8= +golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= +golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= +golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= +golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/postgres v1.6.0 h1:2dxzU8xJ+ivvqTRph34QX+WrRaJlmfyPqXmoGVjMBa4= +gorm.io/driver/postgres v1.6.0/go.mod h1:vUw0mrGgrTK+uPHEhAdV4sfFELrByKVGnaVRkXDhtWo= +gorm.io/gorm v1.31.0 h1:0VlycGreVhK7RF/Bwt51Fk8v0xLiiiFdbGDPIZQ7mJY= +gorm.io/gorm v1.31.0/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs= diff --git a/apps/api-go/main.go b/apps/api-go/main.go new file mode 100644 index 00000000..0b165a2f --- /dev/null +++ b/apps/api-go/main.go @@ -0,0 +1,65 @@ +package main + +import ( + "os" + + config "github.com/ValoryLabs/monorepo/app" + fiber_middleware "github.com/ValoryLabs/monorepo/app/middlewares" + routes "github.com/ValoryLabs/monorepo/app/routes" + utils "github.com/ValoryLabs/monorepo/app/utils" + "github.com/gofiber/fiber/v2" + + _ "github.com/joho/godotenv/autoload" // load .env file automatically + + "github.com/danielgtaylor/huma/v2" + "github.com/danielgtaylor/huma/v2/adapters/humafiber" +) + +func main() { + config := config.FiberConfig() + + app := fiber.New(config) + + fiber_middleware.FiberMiddleware(app) + + humaConfig := huma.DefaultConfig("Valory API", "1.0.0") + humaConfig.Info.Description = "Valory API" + + humaConfig.OpenAPIPath = "/openapi" + humaConfig.DocsPath = "" + humaConfig.SchemasPath = "schemas" + + humaConfig.Servers = []*huma.Server{ + {URL: "http://" + os.Getenv("SERVER_URL") + "/", Description: "Development server"}, + } + + api := humafiber.New(app, humaConfig) + + app.Get("/docs", func(c *fiber.Ctx) error { + var html = []byte(` + + + Valory API Documentation + + + + + + + + +`) + c.Set("Content-Type", "text/html") + return c.Send(html) + }) + + routes.UsersRoutes(app, api) + routes.PingRoutes(app, api) + + utils.StartServer(app) +} diff --git a/apps/api-go/package.json b/apps/api-go/package.json new file mode 100644 index 00000000..21449400 --- /dev/null +++ b/apps/api-go/package.json @@ -0,0 +1,11 @@ +{ + "name": "api-go", + "version": "0.0.0", + "private": true, + "scripts": { + "dev": "air", + "build": "go build -o backend_go main.go", + "dev:linux": "air -c .air.linux.conf", + "dev:windows": "air -c .air.windows.conf" + } +} diff --git a/apps/api/app/migrations/versions/3721e17267b0_.py b/apps/api/app/migrations/versions/3721e17267b0_.py new file mode 100644 index 00000000..5520b869 --- /dev/null +++ b/apps/api/app/migrations/versions/3721e17267b0_.py @@ -0,0 +1,30 @@ +"""empty message + +Revision ID: 3721e17267b0 +Revises: +Create Date: 2025-09-10 18:25:40.142602 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '3721e17267b0' +down_revision: Union[str, None] = None +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### diff --git a/apps/api/app/migrations/versions/b5571133c972_.py b/apps/api/app/migrations/versions/b5571133c972_.py new file mode 100644 index 00000000..ef9d8c1e --- /dev/null +++ b/apps/api/app/migrations/versions/b5571133c972_.py @@ -0,0 +1,102 @@ +"""empty message + +Revision ID: b5571133c972 +Revises: 3721e17267b0 +Create Date: 2025-09-10 18:26:49.640633 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = 'b5571133c972' +down_revision: Union[str, None] = '3721e17267b0' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('users', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='Unique identifier for the user'), + sa.Column('username', sa.String(length=50), nullable=False, comment='Unique username for application login'), + sa.Column('broadcaster_type', sa.String(length=50), nullable=True, comment='Type of broadcaster (e.g., affiliate, partner, etc.)'), + sa.Column('avatar_url', sa.String(length=500), nullable=True, comment="URL to user's profile picture"), + sa.Column('twitch_id', sa.String(length=100), nullable=True, comment='Twitch platform user identifier'), + sa.Column('twitch_display_name', sa.String(length=100), nullable=True, comment='Display name shown on Twitch platform'), + sa.Column('riot_id', sa.String(length=100), nullable=True, comment='Riot Games account identifier (username#tag format)'), + sa.Column('hdev_api_key', sa.String(length=200), nullable=True, comment='Henrik Dev API key for VALORANT statistics access'), + sa.Column('is_active', sa.Boolean(), nullable=False, comment='Account status flag - False for suspended/deleted accounts'), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False, comment='Account creation timestamp'), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False, comment='Last account modification timestamp'), + sa.CheckConstraint("avatar_url IS NULL OR avatar_url ~ '^https?://'", name='ck_users_avatar_url_format'), + sa.CheckConstraint("length(username) >= 3 AND username ~ '^[a-zA-Z0-9_-]+$'", name='ck_users_username_format'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('twitch_id', name='uq_users_twitch_id'), + comment='Application users with gaming platform integrations' + ) + op.create_index('ix_users_active_created', 'users', ['is_active', 'created_at'], unique=False) + op.create_index(op.f('ix_users_twitch_id'), 'users', ['twitch_id'], unique=True) + op.create_index('ix_users_twitch_lookup', 'users', ['twitch_id', 'twitch_display_name'], unique=False) + op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True) + op.create_table('overlays', + sa.Column('id', sa.UUID(), nullable=False, comment='Unique identifier for the overlay configuration'), + sa.Column('user_id', sa.Integer(), nullable=False, comment='Reference to the user who owns this overlay'), + sa.Column('overlay_style', sa.String(length=20), nullable=False, comment='Visual style variant for the overlay presentation'), + sa.Column('background_color', sa.String(length=7), nullable=False, comment='Primary background color in hexadecimal format'), + sa.Column('disabled_background', sa.Boolean(), nullable=False, comment='Flag to disable background rendering'), + sa.Column('disabled_border', sa.Boolean(), nullable=False, comment='Flag to disable border rendering around overlay elements'), + sa.Column('disabled_background_gradient', sa.Boolean(), nullable=False, comment='Flag to disable gradient effects on background'), + sa.Column('disabled_glow_effect', sa.Boolean(), nullable=False, comment='Flag to disable glow visual effects'), + sa.Column('disabled_peak_rank_icon', sa.Boolean(), nullable=False, comment='Flag to hide peak rank icon display'), + sa.Column('disabled_leaderboard_place', sa.Boolean(), nullable=False, comment='Flag to hide leaderboard position display'), + sa.Column('disabled_peak_rr', sa.Boolean(), nullable=False, comment='Flag to hide peak rating (RR) display'), + sa.Column('text_color', sa.String(length=7), nullable=False, comment='Primary text color in hexadecimal format'), + sa.Column('primary_color', sa.String(length=7), nullable=False, comment='Secondary text color for highlights in hexadecimal format'), + sa.Column('overlay_font', sa.String(length=50), nullable=False, comment='Font family name for text rendering'), + sa.Column('win_color', sa.String(length=7), nullable=False, comment='Color for win indicators in hexadecimal format'), + sa.Column('lose_color', sa.String(length=7), nullable=False, comment='Color for loss indicators in hexadecimal format'), + sa.Column('disabled_win_lose', sa.Boolean(), nullable=False, comment='Flag to hide win/loss indicator display'), + sa.Column('disabled_last_match_points', sa.Boolean(), nullable=False, comment='Flag to hide recent match points display'), + sa.Column('disabled_progress', sa.Boolean(), nullable=False, comment='Flag to hide progress bar display'), + sa.Column('progress_color', sa.String(length=7), nullable=False, comment='Progress bar fill color in hexadecimal format'), + sa.Column('progress_bg_color', sa.String(length=7), nullable=False, comment='Progress bar background color in hexadecimal format'), + sa.Column('is_active', sa.Boolean(), nullable=False, comment='Flag indicating if overlay is currently active'), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False, comment='Timestamp when overlay was created'), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False, comment='Timestamp when overlay was last modified'), + sa.CheckConstraint("background_color ~ '^#[0-9A-Fa-f]{6}$'", name='ck_overlay_background_color_hex'), + sa.CheckConstraint("lose_color ~ '^#[0-9A-Fa-f]{6}$'", name='ck_overlay_lose_color_hex'), + sa.CheckConstraint("overlay_font ~ '^[a-zA-Z0-9\\s-]+$' AND length(overlay_font) >= 2", name='ck_overlay_font_format'), + sa.CheckConstraint("overlay_style IN ('old', 'new', 'minimal', 'new_v2')", name='ck_overlay_style_enum'), + sa.CheckConstraint("primary_color ~ '^#[0-9A-Fa-f]{6}$'", name='ck_overlay_primary_color_hex'), + sa.CheckConstraint("progress_bg_color ~ '^#[0-9A-Fa-f]{6}$'", name='ck_overlay_progress_bg_color_hex'), + sa.CheckConstraint("progress_color ~ '^#[0-9A-Fa-f]{6}$'", name='ck_overlay_progress_color_hex'), + sa.CheckConstraint("text_color ~ '^#[0-9A-Fa-f]{6}$'", name='ck_overlay_text_color_hex'), + sa.CheckConstraint("win_color ~ '^#[0-9A-Fa-f]{6}$'", name='ck_overlay_win_color_hex'), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id'), + comment='Streaming overlay configurations with visual and functional settings' + ) + op.create_index('ix_overlays_style_created', 'overlays', ['overlay_style', 'created_at'], unique=False) + op.create_index('ix_overlays_updated_desc', 'overlays', [sa.literal_column('updated_at DESC')], unique=False) + op.create_index('ix_overlays_user_active', 'overlays', ['user_id', 'is_active'], unique=False) + op.create_index(op.f('ix_overlays_user_id'), 'overlays', ['user_id'], unique=False) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_overlays_user_id'), table_name='overlays') + op.drop_index('ix_overlays_user_active', table_name='overlays') + op.drop_index('ix_overlays_updated_desc', table_name='overlays') + op.drop_index('ix_overlays_style_created', table_name='overlays') + op.drop_table('overlays') + op.drop_index(op.f('ix_users_username'), table_name='users') + op.drop_index('ix_users_twitch_lookup', table_name='users') + op.drop_index(op.f('ix_users_twitch_id'), table_name='users') + op.drop_index('ix_users_active_created', table_name='users') + op.drop_table('users') + # ### end Alembic commands ### diff --git a/apps/caddy/Caddyfile.dev b/apps/caddy/Caddyfile.dev index ecd3c2d2..fbd1bf88 100644 --- a/apps/caddy/Caddyfile.dev +++ b/apps/caddy/Caddyfile.dev @@ -12,3 +12,8 @@ api.valory.localhost { tls internal reverse_proxy 127.0.0.1:8000 } + +go.api.valorant.localhost { + tls internal + reverse_proxy 127.0.0.1:8080 +} diff --git a/apps/web/src/components/features/configuration-page/settings/Settings.vue b/apps/web/src/components/features/configuration-page/settings/Settings.vue new file mode 100644 index 00000000..8a5a6f05 --- /dev/null +++ b/apps/web/src/components/features/configuration-page/settings/Settings.vue @@ -0,0 +1,56 @@ + + + diff --git a/apps/web/src/components/features/home-page/GetStarted.vue b/apps/web/src/components/features/home-page/GetStarted.vue new file mode 100644 index 00000000..0a98aa7b --- /dev/null +++ b/apps/web/src/components/features/home-page/GetStarted.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/apps/web/src/pages/configurator/Settings.vue b/apps/web/src/pages/configurator/Settings.vue new file mode 100644 index 00000000..4e8687b2 --- /dev/null +++ b/apps/web/src/pages/configurator/Settings.vue @@ -0,0 +1,15 @@ + + +