repository

package
v0.0.0-...-8e7fc4b Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgresDB

func NewPostgresDB(conf Config) (*sqlx.DB, error)

NewPostgresDB - postgres connection

func NewRedisDB

func NewRedisDB(config RedisConfig) *redis.Client

Types

type AuthRepo

type AuthRepo struct {
	// contains filtered or unexported fields
}

func NewAuthRepo

func NewAuthRepo(db *sqlx.DB, rdb *redis.Client) *AuthRepo

func (*AuthRepo) BlacklistToken

func (r *AuthRepo) BlacklistToken(token string, expiresAt int64) error

func (*AuthRepo) CheckIfTokenBlacklisted

func (r *AuthRepo) CheckIfTokenBlacklisted(token string) bool

func (*AuthRepo) CreateUser

func (r *AuthRepo) CreateUser(user snippets.User) (int, error)

func (*AuthRepo) GetUser

func (r *AuthRepo) GetUser(username, password string) (snippets.User, error)

GetUser - get user from db

func (*AuthRepo) RemoveExpiredTokensFromBlacklist

func (r *AuthRepo) RemoveExpiredTokensFromBlacklist(timestamp int64) error

type Authorization

type Authorization interface {
	CreateUser(user snippets.User) (int, error)
	GetUser(username, password string) (snippets.User, error)
	BlacklistToken(token string, expiresAt int64) error
	CheckIfTokenBlacklisted(token string) bool
	RemoveExpiredTokensFromBlacklist(timestamp int64) error
}

Authorization repo entity interface

type Config

type Config struct {
	Username string
	Password string
	Host     string
	Port     string
	DBName   string
}

Config db

type FavouriteSnippet

type FavouriteSnippet interface {
	Create(userID int, snippetID int) error
	GetAll(userID int) ([]int, error)
	Delete(userID, snippetID int) error
}

FavouriteSnippet repo entity interface

type FavouriteSnippetPostgres

type FavouriteSnippetPostgres struct {
	// contains filtered or unexported fields
}

FavouriteSnippetPostgres structure

func NewFavouriteSnippetPostgres

func NewFavouriteSnippetPostgres(db *sqlx.DB) *FavouriteSnippetPostgres

NewFavouriteSnippetPostgres - FavouriteSnippetPostgres constructor

func (*FavouriteSnippetPostgres) Create

func (r *FavouriteSnippetPostgres) Create(userID, snippetID int) error

Create - create new favourite snippet

func (*FavouriteSnippetPostgres) Delete

func (r *FavouriteSnippetPostgres) Delete(userID, snippetID int) error

Delete - remove snippet from favourites

func (*FavouriteSnippetPostgres) GetAll

func (r *FavouriteSnippetPostgres) GetAll(userID int) ([]int, error)

GetAll - get all favourite snippet ids

type Language

type Language interface {
	GetAll() ([]snippets.Language, error)
	Create(snippets.Language) (int, error)
}

Language repo entity interface

type LanguagePostgres

type LanguagePostgres struct {
	// contains filtered or unexported fields
}

LanguagePostgres structure

func NewLanguagePostgres

func NewLanguagePostgres(db *sqlx.DB) *LanguagePostgres

NewLanguagePostgres - LanguagePostgres constructor

func (*LanguagePostgres) Create

func (r *LanguagePostgres) Create(language snippets.Language) (int, error)

Create - create language

func (*LanguagePostgres) GetAll

func (r *LanguagePostgres) GetAll() ([]snippets.Language, error)

GetAll - get list of languages

type List

type List interface {
	Create(userID int, list snippets.List) (snippets.List, error)
	GetAll(userID int, paginationParams *snippets.PaginationParams) ([]snippets.List, error)
	GetByID(userID int, listID int) (snippets.List, error)
	Delete(userID int, listID int) error
	Update(userID int, listID int, input snippets.UpdateListInput) (snippets.List, error)
}

List repo entity interface

type ListPostgres

type ListPostgres struct {
	// contains filtered or unexported fields
}

ListPostgres structure

func NewListPostgres

func NewListPostgres(db *sqlx.DB) *ListPostgres

NewListPostgres - ListPostgres constructor

func (*ListPostgres) Create

func (r *ListPostgres) Create(userID int, list snippets.List) (snippets.List, error)

Create - create new list

func (*ListPostgres) Delete

func (r *ListPostgres) Delete(userID int, listID int) error

Delete - delete list

func (*ListPostgres) GetAll

func (r *ListPostgres) GetAll(userID int, paginationParams *snippets.PaginationParams) ([]snippets.List, error)

GetAll - get all lists

func (*ListPostgres) GetByID

func (r *ListPostgres) GetByID(userID int, listID int) (snippets.List, error)

GetByID - get list by ID

func (*ListPostgres) Update

func (r *ListPostgres) Update(userID int, listID int, input snippets.UpdateListInput) (snippets.List, error)

Update - update list

type RedisConfig

type RedisConfig struct {
	Host     string
	Port     string
	Password string
	DB       int
}

type Repository

Repository interface

func NewRepository

func NewRepository(db *sqlx.DB, rdb *redis.Client) *Repository

NewRepository - repository constructor

type Snippet

type Snippet interface {
	Create(listID int, snippet snippets.Snippet) (int, error)
	GetAll(userID, listID int, tagIDs string, paginationParams *snippets.PaginationParams) ([]snippets.Snippet, error)
	GetByID(userID, snippetID int) (snippets.Snippet, error)
	Delete(userID, snippetID int) error
	Update(userID, snippetID int, input snippets.UpdateSnippetInput) error
}

Snippet repo entity interface

type SnippetPostgres

type SnippetPostgres struct {
	// contains filtered or unexported fields
}

SnippetPostgres structure

func NewSnippetPostgres

func NewSnippetPostgres(db *sqlx.DB) *SnippetPostgres

NewSnippetPostgres - SnippetPostgres constructor

func (*SnippetPostgres) Create

func (r *SnippetPostgres) Create(listID int, snippet snippets.Snippet) (int, error)

Create - create new snippet

func (*SnippetPostgres) Delete

func (r *SnippetPostgres) Delete(userID, snippetID int) error

Delete - delete snippet

func (*SnippetPostgres) GetAll

func (r *SnippetPostgres) GetAll(userID, listID int, tagIDs string, paginationParams *snippets.PaginationParams) ([]snippets.Snippet, error)

GetAll - get all snippets

func (*SnippetPostgres) GetByID

func (r *SnippetPostgres) GetByID(userID, snippetID int) (snippets.Snippet, error)

GetByID - get snippet by ID

func (*SnippetPostgres) Update

func (r *SnippetPostgres) Update(userID, snippetID int, input snippets.UpdateSnippetInput) error

Update - update snippet

type SnippetTag

type SnippetTag interface {
	Create(userID, snippetID, tagID int) error
	Delete(userID, snippetID, tagID int) error
	GetTagIDs(userID, snippetID int) ([]int, error)
}

SnippetTag relation interface

type SnippetTagPostgres

type SnippetTagPostgres struct {
	// contains filtered or unexported fields
}

SnippetTagPostgres structure

func NewSnippetTagPostgres

func NewSnippetTagPostgres(db *sqlx.DB) *SnippetTagPostgres

NewSnippetTagPostgres - SnippetTagPostgres constructor

func (*SnippetTagPostgres) Create

func (r *SnippetTagPostgres) Create(userID, snippetID, tagID int) error

Create - create snippets to tags relation entry

func (*SnippetTagPostgres) Delete

func (r *SnippetTagPostgres) Delete(userID, snippetID, tagID int) error

Delete - delete snippets to tags relation entry

func (*SnippetTagPostgres) GetTagIDs

func (r *SnippetTagPostgres) GetTagIDs(userID, snippetID int) ([]int, error)

GetTagIDs - get tag ids by snippet id

type Tag

type Tag interface {
	Create(userID int, tag snippets.Tag) (int, error)
	GetAll(userID int) ([]snippets.Tag, error)
	GetByID(userID, tagID int) (snippets.Tag, error)
	Delete(userID, tagID int) error
	Update(userID, tagID int, input snippets.UpdateTagInput) error
}

Tag repo entity interface

type TagPostgres

type TagPostgres struct {
	// contains filtered or unexported fields
}

TagPostgres structure

func NewTagPostgres

func NewTagPostgres(db *sqlx.DB) *TagPostgres

NewTagPostgres - TagPostgres constructor

func (*TagPostgres) Create

func (r *TagPostgres) Create(userID int, tag snippets.Tag) (int, error)

Create - create new tag

func (*TagPostgres) Delete

func (r *TagPostgres) Delete(userID, tagID int) error

Delete - delete tag

func (*TagPostgres) GetAll

func (r *TagPostgres) GetAll(userID int) ([]snippets.Tag, error)

GetAll - get all tags

func (*TagPostgres) GetByID

func (r *TagPostgres) GetByID(userID, tagID int) (snippets.Tag, error)

GetByID - get tag by ID

func (*TagPostgres) Update

func (r *TagPostgres) Update(userID, tagID int, input snippets.UpdateTagInput) error

Update - update tag

Jump to

Keyboard shortcuts

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