Documentation
¶
Index ¶
- Variables
- type AuthService
- type CacheClient
- type CacheFlushOp
- type CacheGetOp
- type CacheSetOp
- func (c *CacheSetOp) Data(data any) *CacheSetOp
- func (c *CacheSetOp) Expiration(expiration time.Duration) *CacheSetOp
- func (c *CacheSetOp) Group(group string) *CacheSetOp
- func (c *CacheSetOp) Key(key string) *CacheSetOp
- func (c *CacheSetOp) Save(ctx context.Context) error
- func (c *CacheSetOp) Tags(tags ...string) *CacheSetOp
- type CacheStore
- type Container
- type InvalidPasswordTokenError
- type NotAuthenticatedError
- type OrgService
- type UserService
- func (s *UserService) Create(ctx context.Context, email, password string) (*ent.User, error)
- func (s *UserService) FindByEmail(ctx context.Context, email string) (*ent.User, error)
- func (s *UserService) FindById(ctx context.Context, id string) (*ent.User, error)
- func (s *UserService) UpdatePassword(ctx context.Context, id string, encryptPassword string) (*ent.User, error)
Constants ¶
This section is empty.
Variables ¶
var ErrCacheMiss = errors.New("cache miss")
ErrCacheMiss indicates that the requested key does not exist in the cache
Functions ¶
This section is empty.
Types ¶
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
func NewAuthService ¶
func NewAuthService(config *config.Config) *AuthService
func (*AuthService) CheckPassword ¶
func (s *AuthService) CheckPassword(password, hash string) error
CheckPassword check if a given password matches a given hash
func (*AuthService) GenToken ¶
func (s *AuthService) GenToken(userId string) (string, error)
GenToken generates a token for a user id using JWT which is set to expire based on the duration stored in configuration
func (*AuthService) HashPassword ¶
func (s *AuthService) HashPassword(password string) (string, error)
HashPassword returns a hash of a given password
func (*AuthService) ParseToken ¶
func (s *AuthService) ParseToken(tokenString string) (*types.MyCustomClaims, error)
type CacheClient ¶
type CacheClient struct {
// contains filtered or unexported fields
}
CacheClient is the client that allows you to interact with the cache
func NewCacheClient ¶
func NewCacheClient(store CacheStore) *CacheClient
NewCacheClient creates a new cache client
func (*CacheClient) Flush ¶
func (c *CacheClient) Flush() *CacheFlushOp
Flush creates a cache flush operation
type CacheFlushOp ¶
type CacheFlushOp struct {
// contains filtered or unexported fields
}
CacheFlushOp handles chaining a flush operation
func (*CacheFlushOp) Execute ¶
func (c *CacheFlushOp) Execute(ctx context.Context) error
Execute flushes the data from the cache
func (*CacheFlushOp) Group ¶
func (c *CacheFlushOp) Group(group string) *CacheFlushOp
Group sets the cache group
func (*CacheFlushOp) Key ¶
func (c *CacheFlushOp) Key(key string) *CacheFlushOp
Key sets the cache key
func (*CacheFlushOp) Tags ¶
func (c *CacheFlushOp) Tags(tags ...string) *CacheFlushOp
Tags sets the cache tags
type CacheGetOp ¶
type CacheGetOp struct {
// contains filtered or unexported fields
}
CacheGetOp handles chaining a get operation
func (*CacheGetOp) Fetch ¶
func (c *CacheGetOp) Fetch(ctx context.Context) (any, error)
Fetch fetches the data from the cache
func (*CacheGetOp) Group ¶
func (c *CacheGetOp) Group(group string) *CacheGetOp
Group sets the cache group
type CacheSetOp ¶
type CacheSetOp struct {
// contains filtered or unexported fields
}
CacheSetOp handles chaining a set operation
func (*CacheSetOp) Data ¶
func (c *CacheSetOp) Data(data any) *CacheSetOp
Data sets the data to cache
func (*CacheSetOp) Expiration ¶
func (c *CacheSetOp) Expiration(expiration time.Duration) *CacheSetOp
Expiration sets the expiration duration of the cached data
func (*CacheSetOp) Group ¶
func (c *CacheSetOp) Group(group string) *CacheSetOp
Group sets the cache group
func (*CacheSetOp) Save ¶
func (c *CacheSetOp) Save(ctx context.Context) error
Save saves the data in the cache
func (*CacheSetOp) Tags ¶
func (c *CacheSetOp) Tags(tags ...string) *CacheSetOp
Tags sets the cache tags
type CacheStore ¶
type CacheStore interface {
// contains filtered or unexported methods
}
CacheStore provides an interface for cache storage
type Container ¶
type Container struct { Web *echo.Echo Config *config.Config Cache *CacheClient Database *sql.DB ORM *ent.Client Auth *AuthService User *UserService Org *OrgService }
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
type InvalidPasswordTokenError ¶
type InvalidPasswordTokenError struct{}
InvalidPasswordTokenError is an error returned when an invalid token is provided
func (InvalidPasswordTokenError) Error ¶
func (e InvalidPasswordTokenError) Error() string
Error implements the error interface.
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 OrgService ¶
type OrgService struct {
// contains filtered or unexported fields
}
func NewOrgService ¶
func NewOrgService(orm *ent.Client) *OrgService
func (*OrgService) Create ¶
func (s *OrgService) Create(ctx context.Context, input *types.OrgCreateInput) (*ent.Org, error)
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func NewUserService ¶
func NewUserService(orm *ent.Client) *UserService