package main

import (
	"os"
	"strconv"
	"time"

	"git.gocasts.ir/ebhomengo/niki/patientapp"
	"git.gocasts.ir/ebhomengo/niki/patientapp/config"
	"git.gocasts.ir/ebhomengo/niki/repository/mysql"
)

func main() {
	dbConf := mysql.Config{
		Username: os.Getenv("DB_USER"),
		Password: os.Getenv("DB_PASS"),
		Host:     os.Getenv("DB_HOST"),
		DBName:   os.Getenv("DB_NAME"),
	}
	port, _ := strconv.Atoi(os.Getenv("DB_PORT"))
	dbConf.Port = port

	db := mysql.New(dbConf)

	cfg := config.Config{
		Port: 8080,
		Cors: config.Cors{
			AllowOrigins: []string{"*"},
		},
		ShutDownCtxTimeout: 5 * time.Second,
	}

	app := patientapp.Setup(cfg, db)

	app.Start()

}
