2023-09-18 00:26:42 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-09-21 15:38:02 +01:00
|
|
|
"fmt"
|
2023-09-19 13:39:59 +01:00
|
|
|
|
2023-10-22 23:02:39 +01:00
|
|
|
"github.com/charmbracelet/log"
|
2023-09-19 13:39:59 +01:00
|
|
|
_ "github.com/lib/pq"
|
2023-09-21 16:43:11 +01:00
|
|
|
|
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"
|
2024-04-13 14:21:38 +01:00
|
|
|
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/tasks"
|
2024-04-12 20:36:23 +01:00
|
|
|
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/tasks/runner"
|
2024-04-17 14:56:57 +01:00
|
|
|
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/users"
|
2024-04-13 14:21:38 +01:00
|
|
|
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/utils"
|
2023-09-19 13:39:59 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
host = "localhost"
|
|
|
|
port = 5432
|
|
|
|
user = "postgres"
|
|
|
|
password = "verysafepassword"
|
|
|
|
dbname = "aistuff"
|
2023-09-18 00:26:42 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2024-04-17 17:46:43 +01:00
|
|
|
|
2023-09-19 13:39:59 +01:00
|
|
|
psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+
|
|
|
|
"password=%s dbname=%s sslmode=disable",
|
|
|
|
host, port, user, password, dbname)
|
|
|
|
|
2024-04-17 17:46:43 +01:00
|
|
|
db := db.StartUp(psqlInfo)
|
2023-09-19 13:39:59 +01:00
|
|
|
defer db.Close()
|
2023-09-18 00:26:42 +01:00
|
|
|
|
2024-04-13 14:21:38 +01:00
|
|
|
config := LoadConfig()
|
|
|
|
log.Info("Config loaded!", "config", config)
|
2024-04-16 17:48:52 +01:00
|
|
|
config.GenerateToken(db)
|
|
|
|
|
2023-10-20 12:37:56 +01:00
|
|
|
//TODO check if file structure exists to save data
|
2024-04-08 15:47:31 +01:00
|
|
|
handle := NewHandler(db, config)
|
2023-09-18 00:26:42 +01:00
|
|
|
|
2024-05-06 01:10:58 +01:00
|
|
|
StartRunners(db, config, handle)
|
|
|
|
|
2024-04-16 18:19:43 +01:00
|
|
|
config.Cleanup(db)
|
2023-09-21 15:38:02 +01:00
|
|
|
|
|
|
|
// 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"})
|
2023-09-21 15:38:02 +01:00
|
|
|
|
2024-04-17 14:56:57 +01:00
|
|
|
UsersEndpints(db, handle)
|
2023-10-20 12:37:56 +01:00
|
|
|
HandleModels(handle)
|
2024-04-13 14:21:38 +01:00
|
|
|
HandleTasks(handle)
|
2024-04-17 21:39:50 +01:00
|
|
|
HandleStats(handle)
|
2023-09-18 00:26:42 +01:00
|
|
|
|
2023-09-18 13:50:03 +01:00
|
|
|
handle.Startup()
|
2023-09-18 00:26:42 +01:00
|
|
|
}
|