service

package
v0.0.0-...-82802e3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenNotValid = fielderr.New(
		"token is not valid",
		map[string]string{
			"token": "is not valid token",
		},
		fielderr.CodeUnauthorized,
	)
	ErrBadTokenType = fielderr.New(
		"bad token type",
		map[string]string{
			"token-type": "token type must be auth-token, bearer or jwt",
		},
		fielderr.CodeBadRequest,
	)
	ErrEmailAlreadyInUse = fielderr.New(
		"email already in use",
		map[string]string{
			"email": "already in use",
		},
		fielderr.CodeConflict,
	)
	ErrInternal = fielderr.New(
		"internal server error",
		nil,
		fielderr.CodeInternal,
	)
	ErrPasswordToLong = fielderr.New(
		"password is too long",
		map[string]string{
			"password": "password is too long",
		},
		fielderr.CodeBadRequest,
	)
	ErrPasswordToEasy = fielderr.New(
		"password is to easy",
		map[string]string{
			"password": "password is too easy",
		},
		fielderr.CodeBadRequest,
	)
	ErrEmailNotValid = fielderr.New(
		"bad request",
		map[string]string{
			"email": "pass valid email address",
		},
		fielderr.CodeConflict,
	)
	ErrBadAuthData = fielderr.New(
		"user not found",
		map[string]string{
			"error": "check password or login",
		},
		fielderr.CodeUnauthorized,
	)
	ErrForbidden = fielderr.New(
		"user has no permission",
		map[string]string{
			"error": "you have no permission to do",
		},
		fielderr.CodeForbidden)
	ErrGroupAlreadyExists = fielderr.New(
		"group already exists",
		map[string]string{
			"name": "group with provided name already exists",
		},
		fielderr.CodeConflict,
	)
	ErrConflict           = fielderr.New("conflict", nil, fielderr.CodeConflict)
	ErrBadData            = fielderr.New("bad data", nil, fielderr.CodeBadRequest)
	ErrBadAuthCredentials = fielderr.New("bad auth credentials", nil, fielderr.CodeUnauthorized)
	ErrNotFound           = fielderr.New("not found", nil, fielderr.CodeNotFound)
	ErrBadInvite          = fielderr.New(
		"invite does not exists",
		map[string]string{
			"invite": "is not available",
		},
		fielderr.CodeNotFound,
	)
	ErrAlreadyInGroup = fielderr.New(
		"user already in group",
		map[string]string{
			"invite": "you are already in group",
		},
		fielderr.CodeConflict,
	)
	ErrNoContent    = fielderr.New("no content", "", fielderr.CodeNotFound)
	ErrUserNotFound = fielderr.New("user not found", map[string]string{
		"user": "not found",
	}, fielderr.CodeNotFound)
	ErrBadInviteLimit = fielderr.New("bad limit", map[string]string{
		"limit": "limit must be not null positive integer number",
	}, fielderr.CodeBadRequest)
	ErrTaskAlreadyExists = fielderr.New("unique violation", "task already exists", fielderr.CodeConflict)
)

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Ping checks access to server.
	Ping(ctx context.Context) error
	// CreateToken create new jwt token for refresh and access to server if auth credits are correct.
	CreateToken(ctx context.Context, username, password, token string) (*model.CreateTokenResponse, error)
	// RegisterUser create record about user in storage and prepares response to user.
	RegisterUser(ctx context.Context, email, password string) (*model.User, error)
	// GetUserFromToken is helper function that decodes jwt token from t and check existing of user which id is provided
	// in token claims.
	GetUserFromToken(ctx context.Context, t string) (uuid.UUID, error)
	// CreateGroup create new group.
	CreateGroup(ctx context.Context, user uuid.UUID, name, description string) (*model.CreateGroupResponse, error)
	// CreateInvite creates invite link on which user will insert into group.
	CreateInvite(ctx context.Context, user uuid.UUID, group uuid.UUID, role *model.Role, limit int) (*model.CreateInviteResponse, error)
	// UseInvite applies use to group if invite data is ok.
	UseInvite(ctx context.Context, user uuid.UUID, group uuid.UUID, invite uuid.UUID) error
	// GetMe ...
	GetMe(ctx context.Context, user uuid.UUID) (*model.GetMeResponse, error)
	// GetUserTasks return all tasks, related to user.
	GetUserTasks(ctx context.Context, user uuid.UUID) (*model.GetTasksResponse, error)
	// GetTask return task by id if user is related to it.
	GetTask(ctx context.Context, user, task uuid.UUID) (*model.Task, error)
	// CreateTask ...
	CreateTask(ctx context.Context, user uuid.UUID, task model.TaskCreateRequest) (*model.Task, error)
}

Interface is service global interface.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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