Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions apps/api-go/.air.linux.conf
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions apps/api-go/.air.windows.conf
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions apps/api-go/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SERVER_URL="0.0.0.0:8080"
SERVER_READ_TIMEOUT=60
3 changes: 3 additions & 0 deletions apps/api-go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
application
application.exe
/tmp
1 change: 1 addition & 0 deletions apps/api-go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go install github.com/air-verse/air@latest
21 changes: 21 additions & 0 deletions apps/api-go/app/config.go
Original file line number Diff line number Diff line change
@@ -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),
}
}
19 changes: 19 additions & 0 deletions apps/api-go/app/controllers/ping.go
Original file line number Diff line number Diff line change
@@ -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
}
33 changes: 33 additions & 0 deletions apps/api-go/app/controllers/users.go
Original file line number Diff line number Diff line change
@@ -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:"[email protected]" 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: "[email protected]"},
{ID: 2, Name: "Jane Smith", Email: "[email protected]"},
}

resp := &GetUsersOutput{}
resp.Body.Users = users
resp.Body.Total = len(users)
resp.Body.Message = "Users retrieved successfully"

return resp, nil
}
21 changes: 21 additions & 0 deletions apps/api-go/app/middlewares/fiber.go
Original file line number Diff line number Diff line change
@@ -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,
}),
)
}
20 changes: 20 additions & 0 deletions apps/api-go/app/models/users.go
Original file line number Diff line number Diff line change
@@ -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"`
}
11 changes: 11 additions & 0 deletions apps/api-go/app/routes/ping.go
Original file line number Diff line number Diff line change
@@ -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)
}
12 changes: 12 additions & 0 deletions apps/api-go/app/routes/users.go
Original file line number Diff line number Diff line change
@@ -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)
}
15 changes: 15 additions & 0 deletions apps/api-go/app/utils/start_server.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
35 changes: 35 additions & 0 deletions apps/api-go/go.mod
Original file line number Diff line number Diff line change
@@ -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
)
63 changes: 63 additions & 0 deletions apps/api-go/go.sum
Original file line number Diff line number Diff line change
@@ -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=
Loading