api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler holds dependencies for API handlers

func NewHandler

func NewHandler(repo Repository, radio Radio, audioResolver audio.Resolver, c *cache.Cache) *Handler

NewHandler creates a new API handler

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers API routes on the given mux

type MoodInfo

type MoodInfo struct {
	Name        string  `json:"name"`
	DisplayName string  `json:"display_name"`
	TrackCount  int     `json:"track_count"`
	TotalMins   float64 `json:"total_minutes"`
}

MoodInfo contains metadata about a mood

type PlaylistTrack

type PlaylistTrack struct {
	ID        int64   `json:"id"`
	FilePath  string  `json:"file_path"`
	AudioURL  string  `json:"audio_url,omitempty"`
	Title     *string `json:"title,omitempty"`
	Artist    *string `json:"artist,omitempty"`
	Energy    string  `json:"energy"`
	Intensity *int    `json:"intensity,omitempty"`
	Lyrics    *string `json:"lyrics,omitempty"`
}

PlaylistTrack is a slim view of a track for playlist responses. The frontend uses only these 8 fields; dropping the other 12 reduces payload size by ~60%.

type Radio

type Radio interface {
	GetPlaylist(mood string, instrumentalOnly bool) ([]*inventory.Track, error)
	RecordPlay(mood string, trackID int64)
}

Radio provides playlist retrieval and play tracking

type Repository

type Repository interface {
	GetMoodStats() ([]inventory.MoodStats, error)
	GetByID(id int64) (*inventory.Track, error)
	BeginTx(ctx context.Context) (*sql.Tx, error)
	UpdatePlayStatsTx(tx *sql.Tx, id int64) error
	RecordListenEventTx(tx *sql.Tx, evt inventory.ListenEvent) error
}

Repository defines the data operations the handler needs

Jump to

Keyboard shortcuts

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