Perbaikan pembacaan data base

This commit is contained in:
2025-08-18 08:45:49 +07:00
parent a7d6005649
commit 6192a64f0a
23 changed files with 1833 additions and 743 deletions

View File

@@ -14,6 +14,8 @@ import (
v1 "api-service/internal/routes/v1"
)
var dbService database.Service // Global variable to hold the database service instance
type Server struct {
port int
db database.Service
@@ -29,9 +31,13 @@ func NewServer() *http.Server {
port = cfg.Server.Port
}
if dbService == nil { // Check if the database service is already initialized
dbService = database.New(cfg) // Initialize only once
}
NewServer := &Server{
port: port,
db: database.New(cfg),
db: dbService, // Use the global database service instance
}
// Declare Server config