feat: persist data in PostgreSQL and add Basic/Bearer sessions in Redis

This commit is contained in:
2026-10-30 01:34:50 +03:00
parent 196e118ede
commit f68710818d
27 changed files with 1229 additions and 214 deletions
+8 -1
View File
@@ -9,8 +9,9 @@ import (
)
type UserRepository interface {
CreateUser(ctx context.Context, u domain.User) error
CreateUser(ctx context.Context, u domain.User, passwordHash string) error
GetUser(ctx context.Context, id uuid.UUID) (domain.User, error)
GetUserByUsername(ctx context.Context, username string) (domain.User, string, error)
}
type ChatRepository interface {
@@ -24,6 +25,12 @@ type MessageRepository interface {
ListMessages(ctx context.Context, chatID uuid.UUID, after *domain.Cursor, limit int) ([]domain.Message, bool, error)
}
type SessionStore interface {
Create(ctx context.Context, tokenHash string, userID uuid.UUID, expiresAt time.Time) error
Get(ctx context.Context, tokenHash string) (uuid.UUID, error)
Delete(ctx context.Context, tokenHash string) error
}
func now() time.Time {
return time.Now().UTC().Truncate(time.Microsecond)
}