fyp/main.go

49 lines
1.2 KiB
Go
Raw Permalink Normal View History

2023-09-18 00:26:42 +01:00
package main
import (
"fmt"
2023-10-22 23:02:39 +01:00
"github.com/charmbracelet/log"
_ "github.com/lib/pq"
2024-04-17 17:46:43 +01:00
"git.andr3h3nriqu3s.com/andr3/fyp/logic/db"
2023-10-20 11:03:07 +01:00
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/models"
2024-04-17 21:39:50 +01:00
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/stats"
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/tasks"
2024-04-12 20:36:23 +01:00
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/tasks/runner"
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/users"
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/utils"
)
2023-09-18 00:26:42 +01:00
func main() {
2024-04-17 17:46:43 +01:00
config := LoadConfig()
log.Info("Config loaded!", "config", config)
psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+
"password=%s dbname=%s sslmode=disable",
config.DbInfo.Host, config.DbInfo.Port, config.DbInfo.User, config.DbInfo.Password, config.DbInfo.Dbname)
2024-04-17 17:46:43 +01:00
db := db.StartUp(psqlInfo)
defer db.Close()
2023-09-18 00:26:42 +01:00
config.GenerateToken(db)
2023-10-20 12:37:56 +01:00
//TODO check if file structure exists to save data
handle := NewHandler(db, config)
2023-09-18 00:26:42 +01:00
StartRunners(db, config, handle)
config.Cleanup(db)
// TODO Handle this in other way
2024-03-02 12:45:49 +00:00
handle.ReadTypesFilesApi("/savedData/", ".", []string{".png", ".jpeg"}, []string{"image/png", "image/jpeg"})
UsersEndpints(db, handle)
2023-10-20 12:37:56 +01:00
HandleModels(handle)
HandleTasks(handle)
2024-04-17 21:39:50 +01:00
HandleStats(handle)
2023-09-18 00:26:42 +01:00
handle.Startup()
2023-09-18 00:26:42 +01:00
}