You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
644 B
Go
38 lines
644 B
Go
2 years ago
|
package routes
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
|
||
|
"github.com/aziis98/lupus-lite/auth"
|
||
|
"github.com/aziis98/lupus-lite/database"
|
||
|
"github.com/aziis98/lupus-lite/events"
|
||
|
"github.com/gofiber/fiber/v2"
|
||
|
)
|
||
|
|
||
|
type Server struct {
|
||
|
db database.Database
|
||
|
auth auth.AuthService
|
||
|
|
||
|
// Live Updates
|
||
|
eventBus *events.EventBus
|
||
|
|
||
|
// Utilities
|
||
|
requireLogged fiber.Handler
|
||
|
}
|
||
|
|
||
|
func NewServer() *Server {
|
||
|
db, err := database.NewInMemoryDB()
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
auth := auth.NewInMemoryAuthService(db)
|
||
|
|
||
|
return &Server{
|
||
|
db: db,
|
||
|
auth: auth,
|
||
|
eventBus: events.NewEventBus(),
|
||
|
requireLogged: RequireLoggedMiddleware(auth),
|
||
|
}
|
||
|
}
|