services

package
v0.0.0-...-43291f5 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SHA

func SHA(str string) string

SHA runs encrypts an input string

Types

type APIRequest

type APIRequest[T models.DTOModel] struct {
	// contains filtered or unexported fields
}

APIRequest is a Generic type struct for organizing dataModel methods

func (*APIRequest[T]) Create

func (api *APIRequest[T]) Create(data T) (T, error)

Create a dataModel

func (*APIRequest[T]) Delete

func (api *APIRequest[T]) Delete() (T, error)

Delete a dataModel

func (*APIRequest[T]) Get

func (api *APIRequest[T]) Get() (T, error)

Get a dataModel

func (*APIRequest[T]) GetAsync

func (api *APIRequest[T]) GetAsync() (*fetch.Fetch, error)

GetAsync a dataModel

func (*APIRequest[T]) LoadModel

func (api *APIRequest[T]) LoadModel(resp *http.Response) (T, error)

LoadModel loads returned json data into a dataModel

func (*APIRequest[T]) Update

func (api *APIRequest[T]) Update(data T) (T, error)

Update a dataModel

type AuthService

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

AuthService manages the authentication system of the app

func NewAuthService

func NewAuthService() *AuthService

NewAuthService initializes a new AuthService

func (*AuthService) AuthHeaders

func (a *AuthService) AuthHeaders(auth *models.Auth) [][]string

AuthHeaders returns authenticated headers

func (*AuthService) Authenticate

func (a *AuthService) Authenticate(user *models.User) (*models.Auth, error)

Authenticate a User

func (*AuthService) Invalidate

func (a *AuthService) Invalidate(auth *models.Auth) (*models.Auth, error)

Invalidate a User session

func (*AuthService) Register

func (a *AuthService) Register(user *models.User) (*models.Auth, error)

Register a new User

func (*AuthService) UpdatePassword

func (a *AuthService) UpdatePassword(pwDTO *models.UpdatePassword, auth *models.Auth) (*models.User, error)

UpdatePassword a User's password

type GroupService

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

GroupService is a Generic type struct for organizing dataModel methods

func NewGroupService

func NewGroupService() *GroupService

NewGroupService initializes and returns a new APIHandler

func (*GroupService) Create

func (s *GroupService) Create(auth *models.Auth, data *models.Group) (*models.Group, error)

Create a dataModel

func (*GroupService) Delete

func (s *GroupService) Delete(auth *models.Auth, filter *models.Group) (*models.Group, error)

Delete a dataModel

func (*GroupService) Get

func (s *GroupService) Get(auth *models.Auth, filter *models.Group) (*models.Group, error)

Get a dataModel

func (*GroupService) GetGroupUsers

func (s *GroupService) GetGroupUsers(auth *models.Auth, filter *models.Group) (*models.GroupUsersDTO, error)

GetGroupUsers returns a models.GroupUsersDTO struct dataModel

func (*GroupService) GetMany

func (s *GroupService) GetMany(auth *models.Auth) ([]*models.Group, error)

GetMany returns a slice of dataModels

func (*GroupService) NewGroupRequest

func (s *GroupService) NewGroupRequest(filter string, auth *models.Auth) *APIRequest[*models.Group]

NewGroupRequest ...

func (*GroupService) NewGroupsRequest

func (s *GroupService) NewGroupsRequest(filter string, auth *models.Auth) *APIRequest[*models.Groups]

NewGroupsRequest ...

func (*GroupService) Update

func (s *GroupService) Update(auth *models.Auth, data *models.Group) (*models.Group, error)

Update a dataModel

type RedisManager

type RedisManager struct {
	Client *redis.Client
	Ctx    context.Context
}

RedisManager is used for managing the web app's user sessions and state

func InitRedisClient

func InitRedisClient() *RedisManager

InitRedisClient initializes a redis manager struct for session management

func (*RedisManager) Del

func (rm *RedisManager) Del(key string) error

Del a RedisManager value

func (*RedisManager) Get

func (rm *RedisManager) Get(key string) (string, error)

Get a RedisManager value

func (*RedisManager) Set

func (rm *RedisManager) Set(key string, value string) error

Set a RedisManager value

type Request

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

Request managers an async request to the API to return data model(s)

func NewRequest

func NewRequest(url string, token string) *Request

NewRequest initializes and returns a new Request struct

func (*Request) Delete

func (dr *Request) Delete() (*fetch.Fetch, error)

Delete a dataModel

func (*Request) Get

func (dr *Request) Get() (*fetch.Fetch, error)

Get returns one or more dataModel

func (*Request) Patch

func (dr *Request) Patch(bodyContents []byte) (*fetch.Fetch, error)

Patch an existing data model

func (*Request) Post

func (dr *Request) Post(bodyContents []byte) (*fetch.Fetch, error)

Post a new dataModel

type SessionService

type SessionService struct {
	RedisManager *RedisManager
}

SessionService is a struct wrapper around an initialized RedisManager

func NewSessionService

func NewSessionService() *SessionService

NewSessionService initializes a Session Manager

func (*SessionService) DeleteSession

func (m *SessionService) DeleteSession(cookie *http.Cookie) error

DeleteSession deletes a user session

func (*SessionService) GetSession

func (m *SessionService) GetSession(cookie *http.Cookie) (*models.Auth, error)

GetSession returns a user Auth session

func (*SessionService) IsLoggedIn

func (m *SessionService) IsLoggedIn(r *http.Request) bool

IsLoggedIn checks if a user making a request is logged in

func (*SessionService) NewSession

func (m *SessionService) NewSession(auth *models.Auth) (*http.Cookie, error)

NewSession initializes a new user session based on an Auth instance

type TaskService

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

TaskService is a Generic type struct for organizing dataModel methods

func NewTaskService

func NewTaskService() *TaskService

NewTaskService initializes and returns a new APIHandler

func (*TaskService) Create

func (s *TaskService) Create(auth *models.Auth, data *models.Task) (*models.Task, error)

Create a dataModel

func (*TaskService) Delete

func (s *TaskService) Delete(auth *models.Auth, filter *models.Task) (*models.Task, error)

Delete a dataModel

func (*TaskService) Get

func (s *TaskService) Get(auth *models.Auth, filter *models.Task) (*models.Task, error)

Get a dataModel

func (*TaskService) GetMany

func (s *TaskService) GetMany(auth *models.Auth) ([]*models.Task, error)

GetMany returns a slice of dataModels

func (*TaskService) NewTaskRequest

func (s *TaskService) NewTaskRequest(filter string, auth *models.Auth) *APIRequest[*models.Task]

NewTaskRequest ...

func (*TaskService) NewTasksRequest

func (s *TaskService) NewTasksRequest(filter string, auth *models.Auth) *APIRequest[*models.Tasks]

NewTasksRequest ...

func (*TaskService) Update

func (s *TaskService) Update(auth *models.Auth, data *models.Task) (*models.Task, error)

Update a dataModel

type UserService

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

UserService is a Generic type struct for organizing dataModel methods

func NewUserService

func NewUserService() *UserService

NewUserService initializes and returns a new APIHandler

func (*UserService) Create

func (s *UserService) Create(auth *models.Auth, data *models.User) (*models.User, error)

Create a dataModel

func (*UserService) Delete

func (s *UserService) Delete(auth *models.Auth, filter *models.User) (*models.User, error)

Delete a dataModel

func (*UserService) Get

func (s *UserService) Get(auth *models.Auth, filter *models.User) (*models.User, error)

Get a dataModel

func (*UserService) GetMany

func (s *UserService) GetMany(auth *models.Auth) ([]*models.User, error)

GetMany returns a slice of dataModels

func (*UserService) NewUserRequest

func (s *UserService) NewUserRequest(filter string, auth *models.Auth) *APIRequest[*models.User]

NewUserRequest ... filter string,

func (*UserService) NewUsersRequest

func (s *UserService) NewUsersRequest(filter string, auth *models.Auth) *APIRequest[*models.Users]

NewUsersRequest ... where filter = "/" + filter.GetID() or just ""

func (*UserService) Update

func (s *UserService) Update(auth *models.Auth, data *models.User) (*models.User, error)

Update a dataModel

Jump to

Keyboard shortcuts

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