models

package
v0.0.0-...-c63bb48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenResponse

type AccessTokenResponse struct {
	AccessToken string    `json:"access_token"`
	TTL         int       `json:"ttl"`
	ExpiredAt   time.Time `json:"expired_at"`
	UserID      string    `json:"user_id"`
}

type AuthClaims

type AuthClaims struct {
	User *UserClaims `json:"user"`
	jwt.StandardClaims
}

type AuthService

type AuthService interface {
	SignUp() (*User, error)
	Login(credentials *dtos.SignInDto) (*AccessTokenResponse, error)
}

type JwtService

type JwtService interface {
	GenerateJwtToken(user *User) (*AccessTokenResponse, error)
	VerifyToken(tokenString string) (*AuthClaims, error)
}

type URL

type URL struct {
	Hash           string    `json:"hash,omitempty"`
	OriginalURL    string    `json:"original_url,omitempty"`
	CreationDate   time.Time `json:"creation_date,omitempty"`
	ExpirationDate time.Time `json:"expiration_date,omitempty"`
	UserID         string    `json:"user_id"`
}

type URLCache

type URLCache interface {
	SetURL(url *URL)
	GetURL(hash string) *URL
}

type URLRepository

type URLRepository interface {
	GetUserURLByHash(hash string, user *UserClaims) (*URL, error)
	GetURLByHash(hash string) (*URL, error)
	GetAllURLs() ([]URL, error)
	CreateURL(createURLDto *dtos.CreateURLDto, user *User) (*URL, error)
}

type URLService

type URLService interface {
	GetUserURLByHash(hash string, user *UserClaims) (*URL, error)
	GetURLByHash(hash string) (*URL, error)
	GetAllURLs() ([]URL, error)
	CreateURL(createURLDto *dtos.CreateURLDto, user *User) (*URL, error)
}

type User

type User struct {
	ID             gocql.UUID `json:"id,omitempty"`
	Username       string     `json:"username,omitempty"`
	Name           string     `json:"name,omitempty"`
	HashedPassword string     `json:"-"`
	Email          string     `json:"email,omitempty"`
	CreationDate   time.Time  `json:"creation_date,omitempty"`
	LastLogin      time.Time  `json:"last_login,omitempty"`
}

func (*User) ComparePassword

func (u *User) ComparePassword(password string) (bool, error)

type UserClaims

type UserClaims struct {
	Username string `json:"username"`
	UserID   string `json:"user_id"`
}

type UserRepository

type UserRepository interface {
	CreateUser(createUserDto *dtos.SignUpDto) (*User, error)
	ValidateUser(credentials *dtos.SignInDto) (*User, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL