services

package
v0.0.0-...-11b8a5d Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2022 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthClient

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

AuthClient is the client that handles authentication requests

func NewAuthClient

func NewAuthClient(cfg *config.Config, orm *ent.Client) *AuthClient

NewAuthClient creates a new authentication client

func (*AuthClient) CheckPassword

func (c *AuthClient) CheckPassword(password, hash string) error

CheckPassword check if a given password matches a given hash

func (*AuthClient) GenerateEmailVerificationToken

func (c *AuthClient) GenerateEmailVerificationToken(email string) (string, error)

GenerateEmailVerificationToken generates an email verification token for a given email address using JWT which is set to expire based on the duration stored in configuration

func (*AuthClient) GetAuthenticatedUser

func (c *AuthClient) GetAuthenticatedUser(ctx echo.Context) (*ent.User, error)

GetAuthenticatedUser returns the authenticated user if the user is logged in

func (*AuthClient) GetAuthenticatedUserID

func (c *AuthClient) GetAuthenticatedUserID(ctx echo.Context) (int, error)

GetAuthenticatedUserID returns the authenticated user's ID, if the user is logged in

func (*AuthClient) HashPassword

func (c *AuthClient) HashPassword(password string) (string, error)

HashPassword returns a hash of a given password

func (*AuthClient) Login

func (c *AuthClient) Login(ctx echo.Context, userID int) error

Login logs in a user of a given ID

func (*AuthClient) Logout

func (c *AuthClient) Logout(ctx echo.Context) error

Logout logs the requesting user out

func (*AuthClient) RandomToken

func (c *AuthClient) RandomToken(length int) (string, error)

RandomToken generates a random token string of a given length

func (*AuthClient) ValidateEmailVerificationToken

func (c *AuthClient) ValidateEmailVerificationToken(token string) (string, error)

ValidateEmailVerificationToken validates an email verification token and returns the associated email address if the token is valid and has not expired

type CacheClient

type CacheClient struct {
	// Client stores the client to the underlying cache service
	Client *redis.Client
	// contains filtered or unexported fields
}

CacheClient is the client that allows you to interact with the cache

func NewCacheClient

func NewCacheClient(cfg *config.Config) (*CacheClient, error)

NewCacheClient creates a new cache client

func (*CacheClient) Close

func (c *CacheClient) Close() error

Close closes the connection to the cache

func (*CacheClient) Flush

func (c *CacheClient) Flush() *cacheFlush

Flush creates a cache flush operation

func (*CacheClient) Get

func (c *CacheClient) Get() *cacheGet

Get creates a cache get operation

func (*CacheClient) Set

func (c *CacheClient) Set() *cacheSet

Set creates a cache set operation

type Container

type Container struct {
	// Validator stores a validator
	Validator *Validator

	// Web stores the web framework
	Web *echo.Echo

	// Config stores the application configuration
	Config *config.Config

	// Cache contains the cache client
	Cache *CacheClient

	// Database stores the connection to the database
	Database *sql.DB

	// ORM stores a client to the ORM
	ORM *ent.Client

	// Mail stores an email sending client
	Mail *MailClient

	// Auth stores an authentication client
	Auth *AuthClient

	// TemplateRenderer stores a service to easily render and cache templates
	TemplateRenderer *TemplateRenderer

	// Tasks stores the task client
	Tasks *TaskClient
}

Container contains all services used by the application and provides an easy way to handle dependency injection including within tests

func NewContainer

func NewContainer() *Container

NewContainer creates and initializes a new Container

func (*Container) Shutdown

func (c *Container) Shutdown() error

Shutdown shuts the Container down and disconnects all connections

type InvalidPasswordTokenError

type InvalidPasswordTokenError struct{}

InvalidPasswordTokenError is an error returned when an invalid token is provided

func (InvalidPasswordTokenError) Error

Error implements the error interface.

type MailClient

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

MailClient provides a client for sending email This is purposely not completed because there are many different methods and services for sending email, many of which are very different. Choose what works best for you and populate the methods below

func NewMailClient

func NewMailClient(cfg *config.Config, templates *TemplateRenderer) (*MailClient, error)

NewMailClient creates a new MailClient

func (*MailClient) Compose

func (m *MailClient) Compose() *mail

Compose creates a new email

type NotAuthenticatedError

type NotAuthenticatedError struct{}

NotAuthenticatedError is an error returned when a user is not authenticated

func (NotAuthenticatedError) Error

func (e NotAuthenticatedError) Error() string

Error implements the error interface.

type TaskClient

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

TaskClient is that client that allows you to queue or schedule task execution

func NewTaskClient

func NewTaskClient(cfg *config.Config) *TaskClient

NewTaskClient creates a new task client

func (*TaskClient) Close

func (t *TaskClient) Close() error

Close closes the connection to the task service

func (*TaskClient) New

func (t *TaskClient) New(typ string) *task

New starts a task creation operation

func (*TaskClient) StartScheduler

func (t *TaskClient) StartScheduler() error

StartScheduler starts the scheduler service which adds scheduled tasks to the queue This must be running in order to queue tasks set for periodic execution

type TemplateParsed

type TemplateParsed struct {
	// Template is the parsed template
	Template *template.Template
	// contains filtered or unexported fields
}

TemplateParsed is a wrapper around parsed templates which are stored in the TemplateRenderer cache

func (*TemplateParsed) Execute

func (t *TemplateParsed) Execute(data interface{}) (*bytes.Buffer, error)

Execute executes a template with the given data and provides the output

type TemplateRenderer

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

TemplateRenderer provides a flexible and easy to use method of rendering simple templates or complex sets of templates while also providing caching and/or hot-reloading depending on your current environment

func NewTemplateRenderer

func NewTemplateRenderer(cfg *config.Config) *TemplateRenderer

NewTemplateRenderer creates a new TemplateRenderer

func (*TemplateRenderer) GetTemplatesPath

func (t *TemplateRenderer) GetTemplatesPath() string

GetTemplatesPath gets the complete path to the templates directory

func (*TemplateRenderer) Load

func (t *TemplateRenderer) Load(group, key string) (*TemplateParsed, error)

Load loads a template from the cache

func (*TemplateRenderer) Parse

func (t *TemplateRenderer) Parse() *templateBuilder

Parse creates a template build operation

type Validator

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

Validator provides validation mainly validating structs within the web context

func NewValidator

func NewValidator() *Validator

NewValidator creats a new Validator

func (*Validator) Validate

func (v *Validator) Validate(i interface{}) error

Validate validates a struct

Jump to

Keyboard shortcuts

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