api

package
v0.0.0-...-f028939 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2026 License: AGPL-3.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MetricsMiddleware

func MetricsMiddleware(next http.Handler) http.Handler

MetricsMiddleware records request count and latency for all HTTP requests.

func OpenAPISpecHandler

func OpenAPISpecHandler(specPath string) http.Handler

OpenAPISpecHandler serves the raw OpenAPI spec from a file path.

func RateLimitMiddleware

func RateLimitMiddleware(log *slog.Logger) func(http.Handler) http.Handler

RateLimitMiddleware applies per-IP rate limiting. In production, replace memory store with a Dragonfly-backed store for distributed rate limiting across multiple instances.

func RegisterScanWorker

func RegisterScanWorker(h *ScanHandler, wr *river.Workers)

RegisterScanWorker registers the scan worker with River's workers registry.

func ScalarHandler

func ScalarHandler() http.Handler

ScalarHandler serves the Scalar API documentation UI.

func SentryMiddleware

func SentryMiddleware(next http.Handler) http.Handler

SentryMiddleware captures panics and reports them to Sentry.

Types

type APITokenHandler

type APITokenHandler struct {
	// contains filtered or unexported fields
}

APITokenHandler provides client API token management.

func NewAPITokenHandler

func NewAPITokenHandler(authSvc *auth.Service, repo *storage.Repository, log *slog.Logger) *APITokenHandler

func (*APITokenHandler) Create

func (h *APITokenHandler) Create(w http.ResponseWriter, r *http.Request)

Create generates a new API token. The plaintext token is only returned once.

func (*APITokenHandler) Delete

func (h *APITokenHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete revokes an API token.

func (*APITokenHandler) List

List returns the user's API tokens (token values are hashed, not revealed).

type AchievementsHandler

type AchievementsHandler struct {
	// contains filtered or unexported fields
}

AchievementsHandler provides RetroAchievements HTTP handlers.

func NewAchievementsHandler

func NewAchievementsHandler(ra *achievements.Service, repo *storage.Repository, log *slog.Logger) *AchievementsHandler

func (*AchievementsHandler) GetRomAchievements

func (h *AchievementsHandler) GetRomAchievements(w http.ResponseWriter, r *http.Request)

type AcquireHandlers

type AcquireHandlers struct {
	// contains filtered or unexported fields
}

AcquireHandlers provides the arr-style HTTP endpoints.

func NewAcquireHandlers

func NewAcquireHandlers(repo *storage.Repository, riverClient *river.Client[pgx.Tx], log *slog.Logger) *AcquireHandlers

func (*AcquireHandlers) AcceptRelease

func (h *AcquireHandlers) AcceptRelease(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) CancelDownloadJob

func (h *AcquireHandlers) CancelDownloadJob(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) CreateDownloadClient

func (h *AcquireHandlers) CreateDownloadClient(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) CreateIndexer

func (h *AcquireHandlers) CreateIndexer(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) CreateWanted

func (h *AcquireHandlers) CreateWanted(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) DeleteDownloadClient

func (h *AcquireHandlers) DeleteDownloadClient(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) DeleteIndexer

func (h *AcquireHandlers) DeleteIndexer(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) DeleteWanted

func (h *AcquireHandlers) DeleteWanted(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) GetCollectionImport

func (h *AcquireHandlers) GetCollectionImport(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) ListCollectionImports

func (h *AcquireHandlers) ListCollectionImports(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) ListDownloadClients

func (h *AcquireHandlers) ListDownloadClients(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) ListDownloadJobs

func (h *AcquireHandlers) ListDownloadJobs(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) ListIndexers

func (h *AcquireHandlers) ListIndexers(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) ListReleases

func (h *AcquireHandlers) ListReleases(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) ListWanted

func (h *AcquireHandlers) ListWanted(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) RejectRelease

func (h *AcquireHandlers) RejectRelease(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) SearchNow

func (h *AcquireHandlers) SearchNow(w http.ResponseWriter, r *http.Request)

func (*AcquireHandlers) SelectCollectionFiles

func (h *AcquireHandlers) SelectCollectionFiles(w http.ResponseWriter, r *http.Request)

type AuthHandlers

type AuthHandlers struct {
	// contains filtered or unexported fields
}

AuthHandlers provides login/register HTTP handlers.

func NewAuthHandlers

func NewAuthHandlers(auth *domainAuth.Service, oidc *domainAuth.OIDCProvider, repo *storage.Repository, log *slog.Logger) *AuthHandlers

func (*AuthHandlers) Login

func (h *AuthHandlers) Login(w http.ResponseWriter, r *http.Request)

func (*AuthHandlers) OIDCCallback

func (h *AuthHandlers) OIDCCallback(w http.ResponseWriter, r *http.Request)

func (*AuthHandlers) OIDCLogin

func (h *AuthHandlers) OIDCLogin(w http.ResponseWriter, r *http.Request)

func (*AuthHandlers) Register

func (h *AuthHandlers) Register(w http.ResponseWriter, r *http.Request)

type CollectionHandlers

type CollectionHandlers struct {
	// contains filtered or unexported fields
}

CollectionHandlers provides collection CRUD HTTP handlers.

func NewCollectionHandlers

func NewCollectionHandlers(repo *storage.Repository, log *slog.Logger) *CollectionHandlers

func (*CollectionHandlers) AddROM

AddROM adds a ROM to a collection.

func (*CollectionHandlers) Create

func (*CollectionHandlers) Delete

Delete removes a collection.

func (*CollectionHandlers) Get

Get returns a single collection by ID.

func (*CollectionHandlers) List

func (*CollectionHandlers) ListROMs

func (h *CollectionHandlers) ListROMs(w http.ResponseWriter, r *http.Request)

ListROMs returns ROMs in a collection.

func (*CollectionHandlers) RemoveROM

func (h *CollectionHandlers) RemoveROM(w http.ResponseWriter, r *http.Request)

RemoveROM removes a ROM from a collection.

type ExportHandlers

type ExportHandlers struct {
	// contains filtered or unexported fields
}

ExportHandlers provides export and feed HTTP handlers.

func NewExportHandlers

func NewExportHandlers(repo *storage.Repository, log *slog.Logger) *ExportHandlers

func (*ExportHandlers) GamelistXML

func (h *ExportHandlers) GamelistXML(w http.ResponseWriter, r *http.Request)

func (*ExportHandlers) PKGiFeed

func (h *ExportHandlers) PKGiFeed(w http.ResponseWriter, r *http.Request)

func (*ExportHandlers) Pegasus

func (h *ExportHandlers) Pegasus(w http.ResponseWriter, r *http.Request)

func (*ExportHandlers) TinfoilFeed

func (h *ExportHandlers) TinfoilFeed(w http.ResponseWriter, r *http.Request)

func (*ExportHandlers) WebRCadeFeed

func (h *ExportHandlers) WebRCadeFeed(w http.ResponseWriter, r *http.Request)

type FirmwareHandler

type FirmwareHandler struct {
	// contains filtered or unexported fields
}

FirmwareHandler provides BIOS/firmware management HTTP handlers.

func NewFirmwareHandler

func NewFirmwareHandler(repo *storage.Repository, cfg *config.Config, log *slog.Logger) *FirmwareHandler

func (*FirmwareHandler) Delete

func (h *FirmwareHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete removes a firmware file and its DB record.

func (*FirmwareHandler) List

List returns all firmware files for a platform.

func (*FirmwareHandler) Upload

func (h *FirmwareHandler) Upload(w http.ResponseWriter, r *http.Request)

Upload uploads a firmware/BIOS file for a platform.

type Handler

type Handler struct {
	oas.UnimplementedHandler
	// contains filtered or unexported fields
}

Handler implements the ogen-generated Handler interface. It delegates to the repository for database access and domain services for business logic.

func NewHandler

func NewHandler(repo *storage.Repository, log *slog.Logger) *Handler

func (*Handler) GetHealth

func (h *Handler) GetHealth(_ context.Context) (*oas.HealthResponse, error)

func (*Handler) GetStats

func (h *Handler) GetStats(ctx context.Context) (*oas.Stats, error)

func (*Handler) ListCollections

func (h *Handler) ListCollections(_ context.Context) (*oas.CollectionList, error)

func (*Handler) ListDats

func (h *Handler) ListDats(ctx context.Context) (*oas.DatFileList, error)

func (*Handler) ListPlatforms

func (h *Handler) ListPlatforms(ctx context.Context, params oas.ListPlatformsParams) (*oas.PlatformList, error)

func (*Handler) ListRoms

func (h *Handler) ListRoms(ctx context.Context, params oas.ListRomsParams) (*oas.RomList, error)

func (*Handler) ListTasks

func (h *Handler) ListTasks(_ context.Context) (*oas.TaskList, error)

func (*Handler) StartScan

func (h *Handler) StartScan(_ context.Context, req *oas.ScanRequest) (*oas.TaskStatus, error)

type HealthHandler

type HealthHandler struct {
	// contains filtered or unexported fields
}

func NewHealthHandler

func NewHealthHandler(pool *pgxpool.Pool, dragonfly rueidis.Client, log *slog.Logger) *HealthHandler

func (*HealthHandler) ServeHTTP

func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type NetplayHandlers

type NetplayHandlers struct {
	// contains filtered or unexported fields
}

NetplayHandlers provides netplay room HTTP handlers.

func NewNetplayHandlers

func NewNetplayHandlers(hub *netplay.Hub, log *slog.Logger) *NetplayHandlers

func (*NetplayHandlers) CreateRoom

func (h *NetplayHandlers) CreateRoom(w http.ResponseWriter, r *http.Request)

func (*NetplayHandlers) ListRooms

func (h *NetplayHandlers) ListRooms(w http.ResponseWriter, _ *http.Request)

type PairingHandler

type PairingHandler struct {
	// contains filtered or unexported fields
}

PairingHandler manages device pairing with short-lived codes + QR codes.

func NewPairingHandler

func NewPairingHandler(authSvc *auth.Service, repo *storage.Repository, log *slog.Logger) *PairingHandler

func (*PairingHandler) GenerateCode

func (h *PairingHandler) GenerateCode(w http.ResponseWriter, r *http.Request)

GenerateCode creates a pairing code for the authenticated user. The code is valid for 5 minutes and single-use.

func (*PairingHandler) RedeemCode

func (h *PairingHandler) RedeemCode(w http.ResponseWriter, r *http.Request)

RedeemCode is called by the device to exchange a pairing code for an API token. The device provides a name (e.g., "Argosy on Pixel 8").

type ROMHandlers

type ROMHandlers struct {
	// contains filtered or unexported fields
}

ROMHandlers provides ROM CRUD HTTP handlers.

func NewROMHandlers

func NewROMHandlers(repo *storage.Repository, cfg *config.Config, log *slog.Logger) *ROMHandlers

func (*ROMHandlers) Delete

func (h *ROMHandlers) Delete(w http.ResponseWriter, r *http.Request)

func (*ROMHandlers) Download

func (h *ROMHandlers) Download(w http.ResponseWriter, r *http.Request)

func (*ROMHandlers) Get

func (h *ROMHandlers) Get(w http.ResponseWriter, r *http.Request)

func (*ROMHandlers) GetPlatform

func (h *ROMHandlers) GetPlatform(w http.ResponseWriter, r *http.Request)

func (*ROMHandlers) List

func (h *ROMHandlers) List(w http.ResponseWriter, r *http.Request)

func (*ROMHandlers) ListDats

func (h *ROMHandlers) ListDats(w http.ResponseWriter, r *http.Request)

func (*ROMHandlers) ListPlatforms

func (h *ROMHandlers) ListPlatforms(w http.ResponseWriter, r *http.Request)

func (*ROMHandlers) Stats

func (h *ROMHandlers) Stats(w http.ResponseWriter, r *http.Request)

func (*ROMHandlers) Update

func (h *ROMHandlers) Update(w http.ResponseWriter, r *http.Request)

type ScanHandler

type ScanHandler struct {
	// contains filtered or unexported fields
}

ScanHandler handles scan API requests by enqueuing River jobs.

func NewScanHandler

func NewScanHandler(
	riverClient *river.Client[pgx.Tx],
	cfg *config.Config,
	hub *ws.Hub,
	repo *storage.Repository,
	log *slog.Logger,
) *ScanHandler

func (*ScanHandler) StartScan

func (h *ScanHandler) StartScan(w http.ResponseWriter, r *http.Request)

func (*ScanHandler) Worker

func (h *ScanHandler) Worker() *ScanWorker

Worker returns a River worker that delegates to the scanner + persister.

type ScanJobArgs

type ScanJobArgs struct {
	Type        string   `json:"type"`
	PlatformIDs []string `json:"platform_ids,omitempty"`
}

ScanJobArgs are the args passed to the River scan worker.

func (ScanJobArgs) Kind

func (ScanJobArgs) Kind() string

type ScanWorker

type ScanWorker struct {
	river.WorkerDefaults[ScanJobArgs]
	// contains filtered or unexported fields
}

ScanWorker processes scan jobs via River.

func (*ScanWorker) Work

func (w *ScanWorker) Work(ctx context.Context, job *river.Job[ScanJobArgs]) error

type SearchHandler

type SearchHandler struct {
	// contains filtered or unexported fields
}

SearchHandler provides global search across ROMs, platforms, and collections.

func NewSearchHandler

func NewSearchHandler(repo *storage.Repository, log *slog.Logger) *SearchHandler

func (*SearchHandler) Global

func (h *SearchHandler) Global(w http.ResponseWriter, r *http.Request)

Global performs a combined search across ROMs, platforms, and collections.

type SearchResults

type SearchResults struct {
	ROMs        []any `json:"roms"`
	Platforms   []any `json:"platforms"`
	Collections []any `json:"collections"`
	Total       int   `json:"total"`
}

SearchResults contains results from a global search.

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(
	lc fx.Lifecycle,
	cfg *config.Config,
	log *slog.Logger,
	health *HealthHandler,
	wsHub *ws.Hub,
	authSvc *auth.Service,
	authHandlers *AuthHandlers,
	uploadHandler *UploadHandler,
	exportHandlers *ExportHandlers,
	romHandlers *ROMHandlers,
	scanHandler *ScanHandler,
	collectionHandlers *CollectionHandlers,
	netplayHandlers *NetplayHandlers,
	achievementsHandler *AchievementsHandler,
	taskHandler *TaskHandler,
	userROMHandlers *UserROMHandlers,
	sessionHandler *SessionHandler,
	statsHandler *StatsHandler,
	searchHandler *SearchHandler,
	firmwareHandler *FirmwareHandler,
	apiTokenHandler *APITokenHandler,
	usersAdminHandler *UsersAdminHandler,
	settingsHandler *SettingsHandler,
	pairingHandler *PairingHandler,
	acquireHandlers *AcquireHandlers,
) *Server

type SessionHandler

type SessionHandler struct {
	// contains filtered or unexported fields
}

SessionHandler provides play session HTTP handlers.

func NewSessionHandler

func NewSessionHandler(repo *storage.Repository, log *slog.Logger) *SessionHandler

func (*SessionHandler) EndSession

func (h *SessionHandler) EndSession(w http.ResponseWriter, r *http.Request)

EndSession completes a play session.

func (*SessionHandler) StartSession

func (h *SessionHandler) StartSession(w http.ResponseWriter, r *http.Request)

StartSession begins a new play session.

type SettingsHandler

type SettingsHandler struct {
	// contains filtered or unexported fields
}

SettingsHandler provides read-only settings and provider status endpoints. Write operations require admin role and are handled via environment/config.

func NewSettingsHandler

func NewSettingsHandler(cfg *config.Config, metaSvc *metadata.Service, rbac *auth.RBAC, log *slog.Logger) *SettingsHandler

func (*SettingsHandler) Info

Info returns the runtime configuration (with sensitive fields redacted).

func (*SettingsHandler) ProviderStatus

func (h *SettingsHandler) ProviderStatus(w http.ResponseWriter, r *http.Request)

ProviderStatus returns the availability of all metadata providers (admin only).

type StatsHandler

type StatsHandler struct {
	// contains filtered or unexported fields
}

StatsHandler provides aggregated statistics for the dashboard.

func NewStatsHandler

func NewStatsHandler(repo *storage.Repository, log *slog.Logger) *StatsHandler

func (*StatsHandler) CategoryBreakdown

func (h *StatsHandler) CategoryBreakdown(w http.ResponseWriter, r *http.Request)

CategoryBreakdown returns ROM counts by category (rom, hack, translation, etc.).

func (*StatsHandler) GenreBreakdown

func (h *StatsHandler) GenreBreakdown(w http.ResponseWriter, r *http.Request)

GenreBreakdown returns top 20 genres by ROM count.

func (*StatsHandler) Overview

func (h *StatsHandler) Overview(w http.ResponseWriter, r *http.Request)

Overview returns a comprehensive stats overview with counts and percentages.

func (*StatsHandler) PlatformBreakdown

func (h *StatsHandler) PlatformBreakdown(w http.ResponseWriter, r *http.Request)

PlatformBreakdown returns ROM counts per platform for dashboard charts.

func (*StatsHandler) RecentROMs

func (h *StatsHandler) RecentROMs(w http.ResponseWriter, r *http.Request)

RecentROMs returns the N most recently added ROMs for an activity feed.

func (*StatsHandler) RegionBreakdown

func (h *StatsHandler) RegionBreakdown(w http.ResponseWriter, r *http.Request)

RegionBreakdown returns ROM counts by region.

type TaskHandler

type TaskHandler struct {
	// contains filtered or unexported fields
}

TaskHandler provides background task HTTP handlers.

func NewTaskHandler

func NewTaskHandler(riverClient *river.Client[pgx.Tx], log *slog.Logger) *TaskHandler

func (*TaskHandler) List

func (h *TaskHandler) List(w http.ResponseWriter, _ *http.Request)

type UploadHandler

type UploadHandler struct {
	// contains filtered or unexported fields
}

UploadHandler handles ROM and DAT file uploads.

func NewUploadHandler

func NewUploadHandler(cfg *config.Config, riverClient *river.Client[pgx.Tx], log *slog.Logger) *UploadHandler

func (*UploadHandler) UploadDAT

func (h *UploadHandler) UploadDAT(w http.ResponseWriter, r *http.Request)

func (*UploadHandler) UploadROM

func (h *UploadHandler) UploadROM(w http.ResponseWriter, r *http.Request)

type UserROMHandlers

type UserROMHandlers struct {
	// contains filtered or unexported fields
}

UserROMHandlers provides per-user ROM property, notes, and media endpoints.

func NewUserROMHandlers

func NewUserROMHandlers(repo *storage.Repository, log *slog.Logger) *UserROMHandlers

func (*UserROMHandlers) CreateNote

func (h *UserROMHandlers) CreateNote(w http.ResponseWriter, r *http.Request)

CreateNote creates a new note for a ROM.

func (*UserROMHandlers) GetMedia

func (h *UserROMHandlers) GetMedia(w http.ResponseWriter, r *http.Request)

GetMedia returns all media (covers, screenshots, etc.) for a ROM.

func (*UserROMHandlers) GetProps

func (h *UserROMHandlers) GetProps(w http.ResponseWriter, r *http.Request)

GetProps returns the authenticated user's properties for a ROM.

func (*UserROMHandlers) ListNotes

func (h *UserROMHandlers) ListNotes(w http.ResponseWriter, r *http.Request)

ListNotes returns all notes for a ROM (public notes + user's own).

func (*UserROMHandlers) UpdateProps

func (h *UserROMHandlers) UpdateProps(w http.ResponseWriter, r *http.Request)

UpdateProps upserts the authenticated user's ROM properties.

type UsersAdminHandler

type UsersAdminHandler struct {
	// contains filtered or unexported fields
}

UsersAdminHandler provides admin-only user management endpoints.

func NewUsersAdminHandler

func NewUsersAdminHandler(repo *storage.Repository, rbac *auth.RBAC, log *slog.Logger) *UsersAdminHandler

func (*UsersAdminHandler) Delete

Delete removes a user account (admin only).

func (*UsersAdminHandler) List

List returns all users (admin only).

func (*UsersAdminHandler) UpdateRole

func (h *UsersAdminHandler) UpdateRole(w http.ResponseWriter, r *http.Request)

UpdateRole changes a user's role (admin only).

Directories

Path Synopsis
Code generated by ogen, DO NOT EDIT.
Code generated by ogen, DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL