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
+17
View File
@@ -9,6 +9,7 @@ import (
type createUserRequest struct {
Username *string `json:"username"`
DisplayName *string `json:"display_name"`
Password *string `json:"password"`
}
type createChatRequest struct {
@@ -47,6 +48,13 @@ type pageResponse[T any] struct {
NextCursor *string `json:"next_cursor"`
}
type sessionResponse struct {
Token string `json:"token"`
TokenType string `json:"token_type"`
ExpiresAt string `json:"expires_at"`
User userResponse `json:"user"`
}
type healthResponse struct {
Status string `json:"status"`
}
@@ -74,6 +82,15 @@ func toUserResponse(u domain.User) userResponse {
}
}
func toSessionResponse(s domain.Session) sessionResponse {
return sessionResponse{
Token: s.Token,
TokenType: "Bearer",
ExpiresAt: formatTime(s.ExpiresAt),
User: toUserResponse(s.User),
}
}
func toChatResponse(c domain.Chat) chatResponse {
members := make([]string, len(c.MemberIDs))
for i, id := range c.MemberIDs {