add user management functionality with OTP verification and consent handling, DI introduced
This commit is contained in:
24
internal/db/database.go
Normal file
24
internal/db/database.go
Normal file
@ -0,0 +1,24 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"git.logidex.ru/fakz9/logidex-id/internal/config"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
func NewDatabasePool(cfg config.Config) *pgxpool.Pool {
|
||||
ctx := context.Background()
|
||||
connUrl := "postgresql://" + cfg.DB.User + ":" + cfg.DB.Password + "@" + cfg.DB.Host + ":" + strconv.Itoa(cfg.DB.Port) + "/" + cfg.DB.Dbname
|
||||
|
||||
pool, err := pgxpool.New(ctx, connUrl)
|
||||
if err != nil {
|
||||
panic("Failed to connect to database: " + err.Error())
|
||||
}
|
||||
err = pool.Ping(ctx)
|
||||
if err != nil {
|
||||
panic("Failed to ping database: " + err.Error())
|
||||
}
|
||||
return pool
|
||||
}
|
||||
Reference in New Issue
Block a user