Перенести пользователей в PostgreSQL и добавить пароли

This commit is contained in:
2026-10-06 14:54:34 +03:00
parent 46c00436a0
commit 618d3919d1
17 changed files with 482 additions and 219 deletions
+14 -5
View File
@@ -1,12 +1,13 @@
// Package app is the composition root: it builds every module with its
// in-memory stores and mounts them on one HTTP engine. Both the server
// binary and the integration tests start from here.
// stores and mounts them on one HTTP engine. Both the server binary and the
// integration tests start from here.
package app
import (
"log/slog"
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v5/pgxpool"
"messenger/internal/auth"
"messenger/internal/chat"
@@ -22,11 +23,19 @@ type App struct {
Health *health.Handler
}
func New(log *slog.Logger, maxBodyBytes int64) *App {
users := user.NewService(userstore.NewInMemUsers())
// Deps are the shared resources the modules are built on; their lifetime is
// owned by the caller.
type Deps struct {
Log *slog.Logger
DB *pgxpool.Pool
MaxBodyBytes int64
}
func New(d Deps) *App {
users := user.NewService(userstore.NewUsers(d.DB))
chats := chat.NewService(chatstore.NewInMemChats(), chatstore.NewInMemMessages(), users)
engine := httpx.NewEngine(log, maxBodyBytes)
engine := httpx.NewEngine(d.Log, d.MaxBodyBytes)
probes := health.New()
probes.Register(engine)