chore: add sqlite init and config, add repository for sql
ci-agent / build (push) Failing after 26s

This commit is contained in:
d3m0k1d
2026-04-03 22:48:31 +03:00
parent 2ebf374413
commit 28ef2dc1fd
12 changed files with 206 additions and 1 deletions
+37
View File
@@ -1,7 +1,13 @@
package cmd
import (
"log"
"os"
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/docs"
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/internal/config"
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/internal/handlers"
"gitea.d3m0k1d.ru/d3m0k1d/HellreigN/backend/internal/storage"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
@@ -13,6 +19,24 @@ import (
// @description Type "Bearer" followed by a space and the JWT token.
func main() {
cfg_path, ok := os.LookupEnv("CONFIG_FILE")
if !ok {
cfg_path = "/etc/hellreign/config.yml"
}
cfg, err := config.ImportSettings(cfg_path)
if err != nil {
log.Fatalf("Err loading config")
}
db, err := storage.Open(cfg.Database.Token_db)
if err != nil {
log.Fatalf("Err opening database")
}
defer db.Close()
h := handlers.New(db)
agents := handlers.AgentsGroup{Handlers: h}
router := gin.Default()
docs.SwaggerInfo.BasePath = "/api/v1"
docs.SwaggerInfo.Title = "HellreigN"
@@ -20,4 +44,17 @@ func main() {
docs.SwaggerInfo.Description = "API for HellreigN"
docs.SwaggerInfo.Schemes = []string{"http"}
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
v1 := router.Group("/api/v1")
{
agentsGroup := v1.Group("/agents")
{
agentsGroup.GET("", agents.List)
agentsGroup.GET("/:id", agents.GetByID)
agentsGroup.POST("", agents.Create)
}
}
log.Fatal(router.Run(":8080"))
}