config

package
v0.0.0-...-c5189f0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSessionSecretLength = errors.New("session secret must be 16, 24, or 32 bytes")

Functions

func ParseLogLevel

func ParseLogLevel(v string) (slog.Level, error)

Types

type ClientID

type ClientID string

type ClientSecret

type ClientSecret string

type Config

type Config struct {
	ServerPort          string               `env:"SERVER_PORT" envDefault:"8080"`
	LogLevel            slog.Level           `env:"LOG_LEVEL"`
	LogType             LogType              `env:"LOG_TYPE" envDefault:"json"`
	ServerURL           ServerURL            `env:"SERVER_URL" envDefault:"https://fitbit.walnuts.dev/"`
	UserID              UserID               `env:"USER_ID,required"`
	ClientID            ClientID             `env:"CLIENT_ID,required"`
	ClientSecret        ClientSecret         `env:"CLIENT_SECRET,required"`
	CookieSecret        CookieSecret         `env:"COOKIE_SECRET,required"`
	PSQLDSN             PSQLDSN              `envPrefix:"PSQL_"`
	InfluxDBConfig      InfluxDBConfig       `envPrefix:"INFLUXDB_"`
	RecordStartDatetime *RecordStartDatetime `env:"RECORD_START_DATETIME"`
}

func Load

func Load() (Config, error)

type CookieSecret

type CookieSecret string

func ParseCookieSecret

func ParseCookieSecret(v string) (CookieSecret, error)

type InfluxDBConfig

type InfluxDBConfig struct {
	Endpoint  url.URL `env:"ENDPOINT" envDefault:"https://localhost:8086"`
	AuthToken string  `env:"AUTH_TOKEN,required"`
	Org       string  `env:"ORG" envDefault:"admin"`
	Bucket    string  `env:"BUCKET" envDefault:"fitbit_manager"`
}

type LogType

type LogType string
const (
	LogTypeJSON LogType = "json"
	LogTypeText LogType = "text"
)

func ParseLogType

func ParseLogType(v string) (LogType, error)

type PSQLDSN

type PSQLDSN struct {
	Dsn          string `env:"DSN" envDefault:""`
	PSQLHost     string `env:"HOST" envDefault:"localhost"`
	PSQLPort     string `env:"PORT" envDefault:"5432"`
	PSQLDatabase string `env:"DATABASE" envDefault:"fitbit_manager"`
	PSQLUser     string `env:"USER" envDefault:"postgres"`
	PSQLPassword string `env:"PASSWORD,required"`
	PSQLSSLMode  string `env:"SSL_MODE" envDefault:"disable"`
	PSQLTimeZone string `env:"TIMEZONE" envDefault:"Asia/Tokyo"`
}

func (PSQLDSN) String

func (p PSQLDSN) String() string

type RecordStartDatetime

type RecordStartDatetime synchro.Time[tz.AsiaTokyo]

func ParseRecordStartDatetime

func ParseRecordStartDatetime(v string) (RecordStartDatetime, error)

type ServerURL

type ServerURL string

func ParseServerURL

func ParseServerURL(v string) (ServerURL, error)

type UserID

type UserID string

Jump to

Keyboard shortcuts

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