micrach/main.go

43 lines
910 B
Go
Raw Normal View History

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-09-03 02:34:45 +03:00
Db "micrach/db"
2021-08-30 12:09:27 +03:00
Repositories "micrach/repositories"
2021-09-04 21:53:48 +03:00
Utils "micrach/utils"
2021-08-26 16:16:50 +03:00
)
func main() {
Config.Init()
2021-09-03 02:34:45 +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
2021-09-04 21:53:48 +03:00
err := Utils.CreateUploadsFolder()
if err != nil {
log.Panicln(err)
}
2021-08-26 16:16:50 +03:00
router := gin.Default()
2021-08-28 17:34:58 +03:00
router.LoadHTMLGlob("templates/*.html")
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
}