types

package
v0.0.0-...-ff237a8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const LoadersKey = LoadersString("dataloaders")

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Apple

type Apple struct {
	BaseModel

	Variety AppleVariety

	UserID uint
	User   User
}

type AppleConnection

type AppleConnection struct {
	Edges    []*AppleEdge
	PageInfo *PageInfo
}

type AppleEdge

type AppleEdge struct {
	Node   *Apple
	Cursor string
}

type AppleVariety

type AppleVariety string
const (
	Fuji            AppleVariety = "FUJI"
	Gala            AppleVariety = "GALA"
	Honeycrisp      AppleVariety = "HONEYCRISP"
	GoldenDelicious AppleVariety = "GOLDEN_DELICIOUS"
	RedDelicious    AppleVariety = "RED_DELICIOUS"
	GrannySmith     AppleVariety = "GRANNY_SMITH"
	Braeburn        AppleVariety = "BRAEBURN"
	Jonagold        AppleVariety = "JONAGOLD"
	CrippsPink      AppleVariety = "CRIPPS_PINK"
	McIntosh        AppleVariety = "MCINTOSH"
	Empire          AppleVariety = "EMPIRE"
	Jonathan        AppleVariety = "JONATHAN"
	Cortland        AppleVariety = "CORTLAND"
	Winesap         AppleVariety = "WINESAP"
	Ambrosia        AppleVariety = "AMBROSIA"
	CosmicCrisp     AppleVariety = "COSMIC_CRISP"
	Envy            AppleVariety = "ENVY"
	Jazz            AppleVariety = "JAZZ"
)

type AscOrDesc

type AscOrDesc string
const (
	AscOrDescAsc  AscOrDesc = "ASC"
	AscOrDescDesc AscOrDesc = "DESC"
)

type BaseModel

type BaseModel struct {
	ID        uint `gorm:"autoIncrement;primaryKey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func (BaseModel) GetID

func (s BaseModel) GetID() uint

type Claims

type Claims struct {
	Email string
	jwt.RegisteredClaims
}

type ConnectionInput

type ConnectionInput struct {
	Limit     *int
	After     *string
	SortBy    *string
	Direction *AscOrDesc
	Query     *string
	Filters   []*FilterInput
}

type Filter

type Filter struct {
	Key      string
	Value    any
	Operator Operator
}

type FilterInput

type FilterInput struct {
	Field string
	Value []string
}

type HandlerDef

type HandlerDef interface {
	Graphql(repo any) gin.HandlerFunc
	Playground() gin.HandlerFunc
	SomeWebhookHandler(c *gin.Context, e IWorker)
}

type IAuth

type IAuth interface {
	Login(ctx context.Context, li LoginInput) (*JWT, error)
	Signup(ctx context.Context, newuser User, password string) (*JWT, error)
	RefreshToken(ctx context.Context, jwt JWT) (*JWT, error)
	GenerateToken(ctx context.Context, email string, duration time.Duration) (string, error)
	ValidateToken(ctx context.Context, tokenStr string) (*Claims, error)
	CurrentUser(ctx context.Context) (*User, error)
	SetCurrentUser(ctx context.Context, user *User) context.Context
}

type IGenericRepo

type IGenericRepo[T any] interface {
	Create(entity *T) (*T, error)
	Update(entity *T) (*T, error)
	Archive(entity *T) error // soft delete
	Delete(entity *T) error  // hard delete
	ListBy(filters []Filter, preloads ...string) ([]*T, error)
	FindBy(filters []Filter, preloads ...string) (*T, error)
	FuzzyFindBy(key string, value any) ([]*T, error)
	Connection(tx *gorm.DB, tableName string, filter []FilterInput, sortBy string, direction AscOrDesc, limit int, after int) ([]*T, *PageInfo, error)
}

type IQueue

type IQueue interface {
	Clear(ctx context.Context, name string) ([]*asynq.TaskInfo, error)
	TogglePause(ctx context.Context, name string) error
	StartServer(ctx context.Context, workPkg IWorker)
	Get(ctx context.Context, name string) (*asynq.QueueInfo, error)
	Enqueue(ctx context.Context, task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error)
	RunTask(ctx context.Context, queueName string, taskId string) error
	DeleteTask(ctx context.Context, queueName string, taskId string) error
	ArchiveTask(ctx context.Context, queueName string, taskId string) error
}

type ISearch

type ISearch interface {
	Apples(ctx context.Context, input *ConnectionInput) (*AppleConnection, error)
}

type ISomeService

type ISomeService interface {
	SomeMethod(ctx context.Context) error
}

type IWorker

type IWorker interface {
	HandleProcessSomeDataTask(ctx context.Context, t *asynq.Task) error
}

type JWT

type JWT struct {
	AccessToken  string
	RefreshToken string
}

type LoadersString

type LoadersString string

type LoginInput

type LoginInput struct {
	Email    string
	Password string
	OTP      *string
}

type Modeler

type Modeler interface {
	GetID() uint
}

type Operator

type Operator string
const (
	OperatorUnset              Operator = ""
	OperatorGreaterThan        Operator = ">"
	OperatorLessThan           Operator = "<"
	OperatorGreaterThanOrEqual Operator = ">="
	OperatorLessThanOrEqual    Operator = "<="
	OperatorEqual              Operator = "="
	OperatorIn                 Operator = "IN"
	OperatorIncludes           Operator = "@>"
	OperatorILike              Operator = "ILIKE"
)

type PageInfo

type PageInfo struct {
	StartCursor string
	EndCursor   string
	HasNextPage bool
	Count       int
}

type Role

type Role string
const (
	RoleAdmin Role = "admin"
	RoleUser  Role = "user"
)

type Services

type Services struct {
	Auth           IAuth
	Workers        IWorker
	Queue          IQueue
	Search         ISearch
	ExampleService ISomeService
}

type User

type User struct {
	BaseModel
	Email        string `gorm:"unique"`
	PasswordHash string
	Role         Role

	Apples []Apple
}

func (*User) IsAdmin

func (u *User) IsAdmin() bool

Jump to

Keyboard shortcuts

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