uc

package
v0.0.0-...-9165fae Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyInUse = errors.New("this username is already in use")

	ErrNotFound = errors.New("user not found")
)

Functions

func NewFilters

func NewFilters(author, tag, favorite string) []domain.ArticleFilter

Types

type ArticleLogic

type ArticleLogic interface {
	ArticleGet(slug, username string) (*domain.User, *domain.Article, error)
	ArticlePost(username string, article domain.Article) (*domain.User, *domain.Article, error)
	ArticlePut(username, slug string, fieldsToUpdate map[domain.ArticleUpdatableField]*string) (*domain.User, *domain.Article, error)
	ArticleDelete(username, slug string) error
}

type ArticleRW

type ArticleRW interface {
	Create(domain.Article) (*domain.Article, error)
	Save(domain.Article) (*domain.Article, error)
	GetBySlug(slug string) (*domain.Article, error)
	GetByAuthorsNameOrderedByMostRecentAsc(usernames []string) ([]domain.Article, error)
	GetRecentFiltered(filters []domain.ArticleFilter) ([]domain.Article, error)
	Delete(slug string) error
}

type ArticleValidator

type ArticleValidator interface {
	BeforeCreationCheck(article *domain.Article) error
	BeforeUpdateCheck(article *domain.Article) error
}

type ArticlesLogic

type ArticlesLogic interface {
	ArticlesFeed(username string, limit, offset int) (requestingUser *domain.User, articles domain.ArticleCollection, totalArticleCount int, err error)
	GetArticles(username string, limit, offset int, filters []domain.ArticleFilter) (requestingUser *domain.User, articles domain.ArticleCollection, totalArticleCount int, err error)
}

type AuthHandler

type AuthHandler interface {
	GenUserToken(userName string) (token string, err error)
	GetUserName(token string) (userName string, err error)
}

type CommentRW

type CommentRW interface {
	Create(comment domain.Comment) (*domain.Comment, error)
	GetByID(id int) (*domain.Comment, error)
	Delete(id int) error
}

type CommentsLogic

type CommentsLogic interface {
	CommentsGet(slug string) ([]domain.Comment, error)
	CommentsPost(username, slug, comment string) (*domain.Comment, error)
	CommentsDelete(username, slug string, id int) error
}

type FavoritesLogic

type FavoritesLogic interface {
	FavoritesUpdate(username, slug string, favortie bool) (*domain.User, *domain.Article, error)
}

type HandlerConstructor

type HandlerConstructor struct {
	Logger           Logger
	UserRW           UserRW
	ArticleRW        ArticleRW
	CommentRW        CommentRW
	UserValidator    UserValidator
	AuthHandler      AuthHandler
	Slugger          Slugger
	ArticleValidator ArticleValidator
	TagsRW           TagsRW
}

func (HandlerConstructor) New

func (c HandlerConstructor) New() Handler

type Logger

type Logger interface {
	Log(...interface{})
}

Logger : only used to log stuff

type ProfileLogic

type ProfileLogic interface {
	ProfileGet(requestingUserName, userName string) (profile *domain.User, follows bool, err error)
	ProfileUpdateFollow(loggedInUsername, username string, follow bool) (user *domain.User, err error)
}

type Slugger

type Slugger interface {
	NewSlug(string) string
}

type TagsLogic

type TagsLogic interface {
	Tags() ([]string, error)
}

type TagsRW

type TagsRW interface {
	GetAll() ([]string, error)
	Add(newTags []string) error
}

type UserLogic

type UserLogic interface {
	UserCreate(username, email, password string) (user *domain.User, token string, err error)
	UserLogin(email, password string) (user *domain.User, token string, err error)
	UserGet(userName string) (user *domain.User, token string, err error)
	UserEdit(userName string, fieldsToUpdate map[domain.UserUpdatableProperty]*string) (user *domain.User, token string, err error)
}

type UserRW

type UserRW interface {
	Create(username, email, password string) (*domain.User, error)
	GetByName(userName string) (*domain.User, error)
	GetByEmailAndPassword(email, password string) (*domain.User, error)
	Save(user domain.User) error
}

type UserValidator

type UserValidator interface {
	CheckUser(user domain.User) error
}

Jump to

Keyboard shortcuts

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