package backend import ( "context" "music-server/internal/db/repository" "github.com/jackc/pgx/v5/pgxpool" ) // Global variables - these are initialized by InitBackend var ( backendPool *pgxpool.Pool repo *repository.Queries backendCtx context.Context = context.Background() ) // InitBackend initializes the backend package with the database pool. // This should be called once at application startup. func InitBackend(pool *pgxpool.Pool) { backendPool = pool repo = repository.New(pool) backendCtx = context.Background() } // BackendCtx returns the context used by backend operations. // This is exposed for use by the backend functions. func BackendCtx() context.Context { return backendCtx } // BackendRepo returns the repository queries instance. // This is exposed for use by the backend functions. func BackendRepo() *repository.Queries { return repo } // BackendPool returns the underlying database pool. // This is exposed for test utilities that need direct pool access. func BackendPool() *pgxpool.Pool { return backendPool }