forked from mtusi2026/mtusi2026lab2
feat: persist data in PostgreSQL and add Basic/Bearer sessions in Redis
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user