entity

package
v0.0.0-...-dc61bab Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound         = errors.New("user not found")
	ErrUserAlreadyExists    = errors.New("user already exists")
	ErrIncorrectCredentials = errors.New("incorrect credentials")
)

Functions

This section is empty.

Types

type CoreError

type CoreError struct {
	// Code is CAPS_CASE constant error code you can programmatically consume to make resolution decisions from
	Code errorcode.ErrorCode `json:"code" example:"ERROR_CODE"`
	// Message indicate a (usually) human-readable description of the error
	Message string `json:"message" example:"error cause description"`
}

CoreError is a basic representation of API call error

@Description	Basic representation of API call error

func (*CoreError) Error

func (e *CoreError) Error() string

func (*CoreError) ErrorCode

func (e *CoreError) ErrorCode() errorcode.ErrorCode

func (*CoreError) ErrorMessage

func (e *CoreError) ErrorMessage() string

type SuspendedUserError

type SuspendedUserError struct {
	UserID string
}

func (*SuspendedUserError) Error

func (e *SuspendedUserError) Error() string

type Tokens

type Tokens struct {
	AccessToken  string `json:"accessToken" example:"header.payload.signature"`
	RefreshToken string `json:"refreshToken" example:"header.payload.signature"`
}

Tokens is a pair of access and refresh token which uses for auth operations

@Description	Pair of access and refresh token which uses for auth operations

type TokensUIDs

type TokensUIDs struct {
	AccessTokenUID  string `json:"accessTokenUID"`
	RefreshTokenUID string `json:"refreshTokenUID"`
}

TokensUIDs is additional layer of abstraction which we need for security reasons and for performing auth operations

type User

type User struct {
	ID        primitive.ObjectID `json:"id" example:"63a75a2574ef628a127ee972"`
	Username  string             `json:"username" example:"kenplix"`
	Email     string             `json:"email" example:"tolstoi.job@gmail.com"`
	CreatedAt time.Time          `json:"createdAt" example:"2022-12-24T21:49:33.072726+02:00"`
	// UpdatedAt is a date of last user personal information modification
	UpdatedAt time.Time `json:"updatedAt" example:"2022-12-24T21:58:27.072726+02:00"`
	// SuspendedAt is a date when user was suspended through certain reasons (optional)
	SuspendedAt *time.Time `json:"suspendedAt,omitempty" example:"2022-12-25T14:25:58.821989+02:00"`
}

User entity information

@Description	User entity information

type UserModel

type UserModel struct {
	ID           primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	Username     string             `json:"username" bson:"username"`
	Email        string             `json:"email" bson:"email"`
	PasswordHash string             `json:"passwordHash" bson:"passwordHash"`
	CreatedAt    time.Time          `json:"createdAt" bson:"createdAt"`
	UpdatedAt    time.Time          `json:"updatedAt" bson:"updatedAt"`
	SuspendedAt  *time.Time         `json:"suspendedAt,omitempty" bson:"suspendedAt"`
}

func (UserModel) Filter

func (u UserModel) Filter() User

type ValidationError

type ValidationError struct {
	CoreError
	// Field with which validation error related
	Field string `json:"field" example:"invalid field"`
}

ValidationError is a standardized representation of a validation errors

@Description	Standardized representation of a validation errors

func (*ValidationError) Error

func (e *ValidationError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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