feat: initialize project structure with configuration, logging, and Telegram integration

- Added configuration loading from environment variables with default session path handling.
- Implemented a logger using Uber's zap library.
- Created a basic HTTP server with Gin and CORS support.
- Established Telegram client and service for message retrieval.
- Introduced initial API routes and handlers.
- Added necessary dependencies in go.sum.
This commit is contained in:
2026-02-24 12:38:23 +03:30
commit 29cbe6a38d
11 changed files with 531 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
package server
import (
"context"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"go.uber.org/fx"
"go.uber.org/zap"
)
type RouterParams struct {
fx.In
Lifecycle fx.Lifecycle
GinEngine *gin.Engine
Logger *zap.Logger
}
func NewGin() *gin.Engine {
g := gin.New()
g.Use(gin.Recovery())
g.Use(cors.New(cors.Config{
AllowAllOrigins: true,
AllowMethods: []string{"GET"},
AllowHeaders: []string{"Origin", "Content-Type"},
}))
return g
}
func RegisterRoutes(params RouterParams) {
params.Lifecycle.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
params.GinEngine.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
params.Logger.Info("Starting server")
go params.GinEngine.Run(":8080")
params.Logger.Info("Server is running on port 8080")
return nil
},
OnStop: func(ctx context.Context) error {
params.Logger.Info("Stopping server")
return nil
},
})
}