-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (36 loc) · 1.03 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"log"
"net/http"
"github.com/secnex/authentication-api/config"
"github.com/secnex/authentication-api/database"
"github.com/secnex/authentication-api/handlers"
)
func main() {
// Load configuration
cfg := config.Load()
// Connect to database
db, err := database.Connect(cfg.DatabaseURL)
if err != nil {
log.Fatalf("Failed to connect to database: %v", err)
}
defer db.Close()
if cfg.Environment == "development" {
// Initialize test user
if err := database.InitializeTestUser(db); err != nil {
log.Printf("[WARN] Failed to initialize test user: %v", err)
// Continue execution even if test user creation fails
} else {
log.Printf("[INFO] Test user credentials:")
log.Printf("[INFO] Username: testuser")
log.Printf("[INFO] Password: password123")
}
}
// Create router
router := handlers.NewRouter(db)
// Start server
log.Printf("[INFO] Auth-API starting on port %s", cfg.Port)
if err := http.ListenAndServe(":"+cfg.Port, router); err != nil {
log.Fatalf("Server error: %v", err)
}
}