Skip to content

armgit / lyftr

Public Imported from GitHub
0

Self-hosted fitness tracker. Log workouts, track nutrition, and monitor progress. Docker deployment, mobile-friendly.

617 B
Raw Blame
package controllers

import (
	"github.com/Cawlumm/lyftr-backend/middleware"
	"github.com/Cawlumm/lyftr-backend/stores"
)

// Handler carries the injected stores. Every HTTP handler is a method on Handler
// so it reaches the database only through h.s.<Entity>, never the global db.DB.
type Handler struct {
	s *stores.Stores
}

func NewHandler(s *stores.Stores) *Handler { return &Handler{s: s} }

// TokenVersions is the handler's user store as the auth middleware needs it, so routes can
// wire Auth without reaching into the stores.
func (h *Handler) TokenVersions() middleware.TokenVersions { return h.s.User }