2023-07-04 16:24:58 +00:00
|
|
|
package web
|
2023-07-04 15:53:14 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
"github.com/jinzhu/gorm"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Server struct {
|
|
|
|
db *gorm.DB
|
|
|
|
log *logrus.Logger
|
|
|
|
router *fiber.App
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewServer is a constructor for Server struct
|
|
|
|
// It takes a database connection and a logger as parameters
|
|
|
|
// It returns a pointer to a Server struct
|
|
|
|
func NewServer(db *gorm.DB, log *logrus.Logger) *Server {
|
|
|
|
app := fiber.New()
|
|
|
|
return &Server{
|
|
|
|
db: db,
|
|
|
|
log: log,
|
|
|
|
router: app,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) Run() {
|
|
|
|
s.router.Listen(":3000")
|
|
|
|
}
|