xmr-remote-nodes/internal/handler/server.go

32 lines
679 B
Go
Raw Normal View History

2024-10-29 14:30:04 +00:00
package handler
import (
"github.com/ditatompel/xmr-remote-nodes/internal/config"
"github.com/ditatompel/xmr-remote-nodes/internal/database"
"github.com/gofiber/fiber/v2"
)
type fiberServer struct {
*fiber.App
2024-11-06 11:00:25 +00:00
db *database.DB
url string
2024-10-29 14:30:04 +00:00
}
// NewServer returns a new fiber server
func NewServer() *fiberServer {
if database.ConnectDB() != nil {
panic("Failed to connect to database")
}
server := &fiberServer{
App: fiber.New(fiber.Config{
Prefork: config.AppCfg().Prefork,
ProxyHeader: config.AppCfg().ProxyHeader,
AppName: "XMR Nodes Aggregator " + config.Version,
}),
2024-11-06 11:00:25 +00:00
db: database.GetDB(),
url: config.AppCfg().URL,
2024-10-29 14:30:04 +00:00
}
return server
}