Separate run command from main function

This commit is contained in:
2024-04-28 22:26:53 +07:00
parent 5ca6cdd129
commit e6344743d5
12 changed files with 74 additions and 79 deletions

View File

@ -15,13 +15,8 @@ import (
var log *logger.AggregatedLogger
// TESTTING VAR
var database db.Database
func init() {
log = logger.Logger()
database = db.NewPostgresDB(utils.Getenv("DB_USERNAME"), utils.Getenv("DB_PASSWORD"), utils.Getenv("DB_HOST"), utils.Getenv("DB_PORT"), utils.Getenv("DB_NAME"))
}
func GET(w http.ResponseWriter, r *http.Request) {
@ -45,7 +40,7 @@ func GET(w http.ResponseWriter, r *http.Request) {
}
userSession := middleware.GetUser(storeSession)
files, err := database.GetFiles(userSession.UserID.String())
files, err := db.DB.GetFiles(userSession.UserID.String())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return