service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidEmailFormat    = errors.New("Invalid email format. Check RFC 5322.")
	ErrInvalidPasswordFormat = errors.New("Password format: Min. 8 chars, atleast 1 number" +
		"1 lowercase char, 1 uppercase char, 1 special char")
	ErrEmailExists          = errors.New("This email already exists.")
	ErrInvalidEmailPassword = errors.New("Invalid email/password combination.")
	ErrNilUser              = errors.New("Nil user.")
	ErrInvalidToken         = errors.New("Invalid token.")
	ErrNoInsert             = errors.New("Insertion failed, check logs.")
	ErrNoFetch              = errors.New("Fetching failed, check logs.")
	ErrNoRemove             = errors.New("Removal failed, check logs.")
	ErrNoPostList           = errors.New("Could not get a list of posts, check logs.")
)

Functions

This section is empty.

Types

type Service

type Service struct {
	Repo      *database.Database
	Conn      redis.Conn
	JwtSecret []byte
	Logger    *zap.Logger
}

func (*Service) CreateNote

func (service *Service) CreateNote(ctx context.Context, n *entity.Note) error

func (*Service) CreateTodo

func (service *Service) CreateTodo(ctx context.Context, t *entity.Todo) error

func (*Service) DeleteTodo

func (service *Service) DeleteTodo(ctx context.Context, id string) error

func (*Service) GetAllNotes

func (service *Service) GetAllNotes(ctx context.Context, userId string) (*[]entity.Note, error)

func (*Service) GetAllPendingTodos

func (service *Service) GetAllPendingTodos(ctx context.Context, userId string) (*[]entity.Todo, error)

func (*Service) GetAllPosts

func (service *Service) GetAllPosts(ctx context.Context, directory string) ([]entity.Post, error)

GeAllPosts will read through a directory of posts and list out all the entries, sorted by their first commit date in descending order.

func (*Service) GetNote

func (service *Service) GetNote(ctx context.Context, id string, userId string) (*[]entity.Note, error)

func (*Service) Login

func (service *Service) Login(ctx context.Context, u *entity.User) (string, error)

Login creates a new JWT and returns it if there is no error.

func (*Service) Logout

func (service *Service) Logout(ctx context.Context, token string) error

Logout will put the JWT in the cache which acts as a blacklist.

func (*Service) Signup

func (service *Service) Signup(ctx context.Context, u *entity.User) error

Signup creates a new user in the database if all the checks pass.

func (*Service) UpdateNote

func (service *Service) UpdateNote(ctx context.Context, n *entity.Note) error

func (*Service) UpdateTodo

func (service *Service) UpdateTodo(ctx context.Context, t *entity.Todo) error

func (*Service) VerifyAndDecodeToken

func (service *Service) VerifyAndDecodeToken(ctx context.Context, token string) (string, error)

VerifyAndDecodeToken will get the payload we need if the token is valid.

Jump to

Keyboard shortcuts

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