2021-08-26 16:16:50 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
2021-08-26 17:32:19 +03:00
|
|
|
_ "github.com/joho/godotenv/autoload"
|
2021-08-26 16:16:50 +03:00
|
|
|
|
|
|
|
Config "micrach/config"
|
2021-08-26 20:23:55 +03:00
|
|
|
Controllers "micrach/controllers"
|
2021-08-31 22:10:24 +03:00
|
|
|
Db "micrach/db"
|
2021-08-30 12:09:27 +03:00
|
|
|
Repositories "micrach/repositories"
|
2021-08-26 16:16:50 +03:00
|
|
|
// Utils "micrach/utils"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
Config.Init()
|
2021-08-31 22:10:24 +03:00
|
|
|
Db.Init()
|
|
|
|
defer Db.Pool.Close()
|
2021-08-26 16:16:50 +03:00
|
|
|
gin.SetMode(Config.App.Env)
|
2021-09-01 15:48:39 +03:00
|
|
|
Repositories.Seed()
|
2021-08-26 16:16:50 +03:00
|
|
|
|
|
|
|
router := gin.Default()
|
2021-08-28 17:34:58 +03:00
|
|
|
router.LoadHTMLGlob("templates/*.html")
|
2021-08-28 18:41:34 +03:00
|
|
|
router.Static("/uploads", "./uploads")
|
2021-08-30 23:29:51 +03:00
|
|
|
router.Static("/static", "./static")
|
2021-08-26 20:23:55 +03:00
|
|
|
router.GET("/", Controllers.GetThreads)
|
|
|
|
router.POST("/", Controllers.CreateThread)
|
|
|
|
router.GET("/:threadId", Controllers.GetThread)
|
|
|
|
router.POST("/:threadId", Controllers.UpdateThread)
|
2021-08-26 16:16:50 +03:00
|
|
|
|
2021-08-28 19:30:14 +03:00
|
|
|
log.Println("port", Config.App.Port, "- online")
|
2021-08-26 16:16:50 +03:00
|
|
|
log.Println("all systems nominal")
|
|
|
|
|
2021-08-28 19:30:14 +03:00
|
|
|
router.Run(":" + strconv.Itoa(Config.App.Port))
|
2021-08-26 16:16:50 +03:00
|
|
|
}
|