feat(auth): implement user registration endpoint

This commit is contained in:
2025-06-14 21:46:27 +03:00
parent 795f220e90
commit 54ce479a6e
8 changed files with 278 additions and 6 deletions

View File

@@ -0,0 +1,30 @@
package database
import (
"database/sql"
"log"
"os"
_ "github.com/jackc/pgx/v5/stdlib" // Регистрируем pgx драйвер
)
// Connect устанавливает соединение с базой данных PostgreSQL
func Connect() *sql.DB {
connStr := os.Getenv("DATABASE_URL")
if connStr == "" {
log.Fatal("DATABASE_URL environment variable is not set")
}
db, err := sql.Open("pgx", connStr)
if err != nil {
log.Fatalf("Unable to connect to database: %v\n", err)
}
// Проверяем, что соединение действительно установлено
if err = db.Ping(); err != nil {
log.Fatalf("Unable to ping database: %v\n", err)
}
log.Println("Successfully connected to PostgreSQL!")
return db
}