api

package
v0.0.0-...-cea713b Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const JwtAccessTokenLifetime = 15 * time.Minute
View Source
const JwtRefreshTokenLifetime = 24 * time.Hour

Variables

View Source
var (
	ErrProjectNotFound = errors.New("project not found")
)
View Source
var (
	ErrUserNotFound = errors.New("user not found")
)

Functions

This section is empty.

Types

type Controller

type Controller struct {
	Path   string
	Routes []*Route
}

type Database

type Database[T any] interface {
	WaitForStart()
	GetClient() T
	GetName() string
	Connect() error
	Disconnect() error
	Ping() bool
}

type DatabaseService

type DatabaseService interface {
	ServiceStarter
	AutoReconnect(database Database[any]) error
	Postgres() Database[*gorm.DB]
	Redis() Database[RedisClient]
}

type Duration

type Duration time.Duration

func (Duration) MarshalBinary

func (d Duration) MarshalBinary() ([]byte, error)

func (*Duration) UnmarshalBinary

func (d *Duration) UnmarshalBinary(data []byte) error

type ExternalServicesService

type ExternalServicesService interface {
	ServiceInitializer
	Wakatime() WakatimeService
	Github() GithubService
}

type GithubService

type GithubService interface {
	ListRepositoriesConcurrent(callback ListRepositoriesCallback) error
}

type Handler

type Handler func(c *gin.Context, user User, mainService MainService)

type HeartbeatsResponse

type HeartbeatsResponse[T float64 | Duration] struct {
	Data []HeartbeatsResponseData[T] `json:"data"`
}

type HeartbeatsResponseData

type HeartbeatsResponseData[T float64 | Duration] struct {
	Time T `json:"time"`
}

type HttpMethod

type HttpMethod int
const (
	MethodGet HttpMethod = iota
	MethodPost
	MethodDelete
	MethodPut
	MethodPatch
	MethodAny
)

func (HttpMethod) String

func (m HttpMethod) String() string

func (HttpMethod) ToFunctionFromEngine

func (m HttpMethod) ToFunctionFromEngine(app *gin.Engine) func(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes

type HttpService

type HttpService interface {
	ServiceInitializer
	ServiceStarter
	Engine() *gin.Engine
	RegisterRoutes(...*Route)
	RegisterControllers(...*Controller)
}

type ListRepositoriesCallback

type ListRepositoriesCallback func(repositories []*github.Repository, wg *sync.WaitGroup)

type MainService

type MainService interface {
	Init() error
	Start(errCh chan error)
	Close() error
	Databases() DatabaseService
	Http() HttpService
	Projects() ProjectService
	ExternalServices() ExternalServicesService
	Stats() StatsService
	Tasks() TasksService
	Messages() MessagesService
	Users() UsersService
}

type MessagesService

type MessagesService interface {
	ServiceInitializer
	GetAllMessagesFromScopeId(scopeId uuid.UUID) (messages []*model.Message, err error)
	GetAllMessagesFromScope(scope string) (messages []*model.Message, err error)
	GetMessage(scope, key string) (message *model.Message, err error)
	AddMessage(message *model.Message) (err error)
	UpdateMessage(message *model.Message) (err error)
	AddTranslations(message *model.Message) (err error)
	GetScopeFromName(scopeName string) (scope *model.Scope, err error)
}

type MiddlewareHandler

type MiddlewareHandler func(c *gin.Context, user User, mainService MainService) (next bool)

type ProjectService

type ProjectService interface {
	ServiceInitializer
	GetProject(id uint) (*model.Project, error)
	ListProjects() ([]*model.Project, error)
}

type RedisClient

type RedisClient interface {
	Base() *redis.Client
	ReJson() *rejson.Handler
	GetJsonString(key, path string) (string, error)
	GetJsonInt(key, path string) (int, error)
	GetJsonFloat(key, path string) (float64, error)
	GetJsonBool(key, path string) (bool, error)
	GetJsonObject(key, path string, object interface{}) error
}

type RepositoriesStored

type RepositoriesStored struct {
	PublicRepositories      int `json:"publicRepositories"`
	PrivateRepositories     int `json:"privateRepositories"`
	PublicOwnedRepositories int `json:"publicOwnedRepositories"`
}

func (RepositoriesStored) MarshalBinary

func (r RepositoriesStored) MarshalBinary() ([]byte, error)

func (*RepositoriesStored) UnmarshalBinary

func (r *RepositoriesStored) UnmarshalBinary(data []byte) error

type Route

type Route struct {
	Path                   string
	Method                 HttpMethod
	IsAuthenticated        bool
	AuthenticateMiddleware func(c *gin.Context, user User, mainService MainService)
	Middlewares            []MiddlewareHandler
	Handler                Handler
}

type ServiceInitializer

type ServiceInitializer interface {
	Init(service MainService) error
}

type ServiceSettings

type ServiceSettings struct {
	MustWaitForStart bool
	Priority         int
}

type ServiceStarter

type ServiceStarter interface {
	Start() error
	Close() error
	Settings() ServiceSettings
}

type StatsService

type StatsService interface {
	ServiceInitializer
	GetTotalDevTime() (*TotalDevTimeResponse[Duration], error)
	GetBestDevTimeDay() (Duration, error)
	IsDeveloping() (bool, error)
	GetVisitorCount() (int, error)
	ListRepositories() (*RepositoriesStored, error)
}

type TasksService

type TasksService interface {
	ServiceInitializer
	ServiceStarter
	CheckWakatimeActivityTask() error
}

type TotalDevTimeResponse

type TotalDevTimeResponse[T float64 | Duration] struct {
	Data TotalDevTimeResponseData[T] `json:"data"`
}

func (TotalDevTimeResponse[T]) MarshalBinary

func (t TotalDevTimeResponse[T]) MarshalBinary() ([]byte, error)

func (*TotalDevTimeResponse[T]) UnmarshalBinary

func (t *TotalDevTimeResponse[T]) UnmarshalBinary(data []byte) error

type TotalDevTimeResponseData

type TotalDevTimeResponseData[T float64 | Duration] struct {
	Range        TotalDevTimeResponseDataRange `json:"range"`
	TotalSeconds T                             `json:"total_seconds"`
}

type TotalDevTimeResponseDataRange

type TotalDevTimeResponseDataRange struct {
	Start time.Time `json:"start"`
}

type User

type User interface {
	GetId() uint
	GetUsername() string
	GetEmail() string
	GetPassword() string
	GetPermissions() []string
	HasPermission(permission string) bool
}

type UsersService

type UsersService interface {
	ServiceInitializer
	GetUser(id uint, withPassword ...bool) (User, error)
	GetUserByUsername(username string, withPassword ...bool) (User, error)
	GetUserByEmail(email string, withPassword ...bool) (User, error)
	ListUsers() ([]User, error)
	Register(user User) error
	IsExist(email string) bool
}

type WakatimeService

type WakatimeService interface {
	GetTotalDevTime() (*TotalDevTimeResponse[Duration], error)
	GetBestDevTimeDay() (Duration, error)
	GetTodayHeartbeats() (*HeartbeatsResponse[Duration], error)
	GetLastTodayHeartbeat() (Duration, error)
}

Jump to

Keyboard shortcuts

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