Oauth. Car Backups.

This commit is contained in:
2026-02-04 17:01:54 -06:00
parent 486c07f2d4
commit 4ed5d821da
14 changed files with 524 additions and 62 deletions

View File

@@ -22,22 +22,40 @@ THE SOFTWARE.
package data
import (
"log/slog"
"time"
"git.bullercodeworks.com/brian/expds/data/models"
"github.com/spf13/viper"
)
type Repo struct {
LoadedPDSs map[string]*models.Pds
BestBy time.Duration
BestBy time.Duration
Auth *AuthRepo
handler *AppLogHandler
logFunc func(string, ...any)
}
func NewRepo() (*Repo, error) {
return &Repo{
r := &Repo{
LoadedPDSs: make(map[string]*models.Pds),
BestBy: time.Minute * 15,
}, nil
handler: NewAppLogHandler(nil),
}
if viper.GetBool(KeyDebug) {
r.handler.SetLevel(slog.LevelDebug)
} else {
r.handler.SetLevel(slog.LevelWarn)
}
var err error
r.Auth, err = NewAuthRepo(r)
if err != nil {
return nil, err
}
return r, nil
}
func (r *Repo) GetPDS(atId string) (*models.Pds, error) {
@@ -51,3 +69,9 @@ func (r *Repo) GetPDS(atId string) (*models.Pds, error) {
r.LoadedPDSs[atId] = p
return p, nil
}
func (r *Repo) SetLogFunc(l func(string, ...any)) {
r.logFunc = l
r.handler = NewAppLogHandler(r.logFunc)
slog.SetDefault(slog.New(r.handler))
}