Initial commit

This commit is contained in:
2025-10-27 14:22:19 +03:00
commit c6e7f13800
23 changed files with 1164 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package db
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
"go.uber.org/fx"
)
func NewDBConnection(lc fx.Lifecycle) *pgxpool.Pool {
pool, err := pgxpool.New(context.Background(), "postgresql://postgres:postgres@localhost:5432/postgres?sslmode=disable");
if err != nil {
panic(err.Error())
}
if err := pool.Ping(context.Background()); err != nil {
pool.Close()
panic(err.Error())
}
lc.Append(
fx.StopHook(func() {
pool.Close()
}),
)
return pool
}