Versions in this module Expand all Collapse all v1 v1.0.0 Dec 22, 2024 Changes in this version + var ErrInvalidToken = errors.New("invalid or non-existing token") + var ErrUserAlreadyExists = errors.New("user already exists") + var ErrUserNotFound = errors.New("user not found") + type AccountStatus int + const AccountStatusActive + const AccountStatusBlocked + const AccountStatusDeleted + const AccountStatusNew + type DatabaseStore interface + type GameRow struct + CPUPlayerMode pb.CPUPlayerMode_Enum + Created time.Time + Done bool + GameID string + GameType api.GameType + Host string + HostID string + Move int + ScoreP1 int + ScoreP2 int + Started time.Time + type GameStore interface + InsertHistory func(ctx context.Context, entryType string, gameId string, state *pb.GameState, ...) error + InsertStats func(ctx context.Context, stats *api.WASMStatsRequest) error + ListRecentGames func(ctx context.Context, offset int, limit int) ([]*GameRow, error) + LoadGame func(ctx context.Context, gameId string) (*pb.GameState, error) + StoreGame func(ctx context.Context, hostId string, state *pb.GameState) error + type PostgresStore struct + func NewPostgresStore(ctx context.Context, database_url string) (*PostgresStore, error) + func (s *PostgresStore) AddUser(ctx context.Context, user *User) error + func (s *PostgresStore) Close() error + func (s *PostgresStore) DeleteUser(ctx context.Context, email string) error + func (s *PostgresStore) FindUser(ctx context.Context, email string) (*User, error) + func (s *PostgresStore) InsertHistory(ctx context.Context, entryType string, gameId string, gs *pb.GameState, ...) error + func (s *PostgresStore) InsertStats(ctx context.Context, stats *api.WASMStatsRequest) error + func (s *PostgresStore) ListRecentGames(ctx context.Context, offset int, limit int) ([]*GameRow, error) + func (s *PostgresStore) LoadGame(ctx context.Context, gameId string) (*pb.GameState, error) + func (s *PostgresStore) StoreGame(ctx context.Context, hostId string, gs *pb.GameState) error + func (s *PostgresStore) UpdateUser(ctx context.Context, user *User) error + func (s *PostgresStore) VerifyUser(ctx context.Context, verificationToken string) error + type User struct + AccountStatus AccountStatus + CreatedAt time.Time + Email string + ID string + PasswordHash string + PlayerName string + ResetPasswordToken string + TokenExpiry time.Time + UpdatedAt time.Time + VerificationToken string + type UserStore interface + AddUser func(ctx context.Context, user *User) error + DeleteUser func(ctx context.Context, email string) error + FindUser func(ctx context.Context, email string) (*User, error) + VerifyUser func(ctx context.Context, verificationToken string) error