add initial project structure with configuration, models, and API key authentication

This commit is contained in:
Flavio Fois
2026-03-17 12:21:48 +01:00
commit 08ff1da469
16 changed files with 379 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package models
import (
"encoding/json"
"time"
)
type BugReportStatus string
const (
BugReportStatusOpen BugReportStatus = "open"
BugReportStatusInProgress BugReportStatus = "in_progress"
BugReportStatusResolved BugReportStatus = "resolved"
BugReportStatusClosed BugReportStatus = "closed"
)
type BugReport struct {
ID int64 `db:"id" json:"id"`
UserID *int64 `db:"user_id" json:"user_id"`
Title string `db:"title" json:"title"`
Description string `db:"description" json:"description"`
Status BugReportStatus `db:"status" json:"status"`
SystemInfo json.RawMessage `db:"system_info" json:"system_info,omitempty"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}

View File

@@ -0,0 +1,21 @@
package models
import "time"
type FileRole string
const (
FileRoleAttachment FileRole = "attachment"
FileRoleScreenshot FileRole = "screenshot"
FileRoleLog FileRole = "log"
)
type BugReportFile struct {
ID int64 `db:"id" json:"id"`
BugReportID int64 `db:"bug_report_id" json:"bug_report_id"`
Filename string `db:"filename" json:"filename"`
MimeType string `db:"mime_type" json:"mime_type"`
Role FileRole `db:"role" json:"role"`
Data []byte `db:"data" json:"-"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
}

View File

@@ -0,0 +1,9 @@
package models
import "time"
type RateLimitHWID struct {
HWID string `db:"hwid" json:"hwid"`
Requests int `db:"requests" json:"requests"`
WindowStart time.Time `db:"window_start" json:"window_start"`
}

View File

@@ -0,0 +1,11 @@
package models
import "time"
type Session struct {
ID string `db:"id" json:"id"`
UserID int64 `db:"user_id" json:"user_id"`
Token string `db:"token" json:"token"`
ExpiresAt time.Time `db:"expires_at" json:"expires_at"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
}

21
internal/models/user.go Normal file
View File

@@ -0,0 +1,21 @@
package models
import "time"
type UserRole string
const (
UserRoleAdmin UserRole = "admin"
UserRoleUser UserRole = "user"
)
type User struct {
ID int64 `db:"id" json:"id"`
Username string `db:"username" json:"username"`
Email string `db:"email" json:"email"`
PasswordHash string `db:"password_hash" json:"-"`
Role UserRole `db:"role" json:"role"`
Enabled bool `db:"enabled" json:"enabled"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}