server

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port           string         `env:"PORT" envDefault:"8989"`
	BaseURL        string         `env:"BASE_URL,required"`
	Whoop          Whoop          `envPrefix:"WHOOP_"`
	RateLimit      RateLimit      `envPrefix:"RATE_"`
	WhoopRateLimit WhoopRateLimit `envPrefix:"WHOOP_RATE_LIMIT_"`
	Redis          Redis          `envPrefix:"REDIS_"`
	Database       Database       `envPrefix:"DATABASE_"`
}

func ReadConfig

func ReadConfig() (Config, error)

func (Config) GetClientID

func (c Config) GetClientID() string

func (Config) GetClientSecret

func (c Config) GetClientSecret() string

func (Config) GetRedirectURL

func (c Config) GetRedirectURL() string

type Database

type Database struct {
	URL string `env:"URL,required"`
}

type RateLimit

type RateLimit struct {
	Limit float64 `env:"LIMIT" envDefault:"10"`
	Burst int     `env:"BURST" envDefault:"20"`
}

type Redis

type Redis struct {
	URL string `env:"URL"`
}

type Whoop

type Whoop struct {
	ClientID     string `env:"CLIENT_ID,required"`
	ClientSecret string `env:"CLIENT_SECRET,required"`
}

type WhoopRateLimit

type WhoopRateLimit struct {
	// per-user daily limit
	PerUserDayLimit int `env:"PER_USER_DAY_LIMIT" envDefault:"1000"`

	// w/ safety buffers from WHOOP's 100/min, 10k/day
	GlobalMinuteLimit int `env:"GLOBAL_MINUTE_LIMIT" envDefault:"95"`
	GlobalDayLimit    int `env:"GLOBAL_DAY_LIMIT" envDefault:"9950"`

	// dynamic per-user minute limiting
	ReserveBuffer         int `env:"RESERVE_BUFFER" envDefault:"5"`            // reserve for new users joining
	MinPerUserMinuteLimit int `env:"MIN_PER_USER_MINUTE_LIMIT" envDefault:"5"` // floor (never go below this)
	ActiveWindowSeconds   int `env:"ACTIVE_WINDOW_SECONDS" envDefault:"60"`    // window for tracking active users
}

Directories

Path Synopsis
Package templates provides HTML templates for server pages.
Package templates provides HTML templates for server pages.

Jump to

Keyboard shortcuts

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