server

package
v0.0.0-...-d0d29b7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APITree    = "/tree"
	APIDisplay = "/display"
	APIAccount = "/account"
	APICreate  = "/create"
	APIUpdate  = "/update"
)
View Source
const (
	CLIAgentID = "Geronimo CLI"

	NameStateDB   = "state.db"
	NameJWTKey    = "jwt-key"
	NameDBKey     = "db-key"
	NameCLICookie = "cli-cookie"

	ExiprationMins = 60

	GeronimoClientID = "Geronimo-Client-ID"
)
View Source
const (
	MessageOK                   = "OK"
	MessageError                = "Error"
	MessageGUIClientCredentials = "GUIClientCredentials"
	MessageAccount              = "Account"
	MessageCommandResponse      = "CommandResponse"
	MessageGetTree              = "GetState"
	MessageTree                 = "State"
	MessageWebServerError       = "WebServerError"
	MessageAuthenticateUser     = "AuthenticateUser"
	MessageUser                 = "UserWithSecret"
	MessageCreateUser           = "CreateUser"
	MessageCreate               = "Create"
	MessageUpdate               = "Update"
	MessageGetDisplay           = "GetDetail"
	MessageDisplay              = "Display"
)
View Source
const (
	RoleUser  = "user"
	RoleAdmin = "admin"
)
View Source
const (
	NodeRoot = iota
	NodeUser
	NodeAccount
	NodeBroker
	NodeGroup
	NodePocket
)
View Source
const (
	StatusActive = iota
	StatusDisabled
)
View Source
const (
	AuthLogin  = "/login"
	AuthSignup = "/signup"
)
View Source
const (
	WSMsg_Credentials = "Credentials"
	WSMsg_Subscribe   = "Subscribe"
	WSMsq_Unsubscribe = "Unsubscribe"
	WSMsg_Update      = "Update"
)

Variables

View Source
var Assets = map[string]Asset{
	"usd": {1, "USD", "USA Dollar"},
	"eur": {2, "EUR", "Euro"},
	"btc": {3, "BTC", "Bitcoin"},
	"eth": {4, "ETH", "Ethereum"},
	"ada": {5, "ADA", "Cardano"},
}
View Source
var StatusKinds = map[string]uint{
	"active":   StatusActive,
	"disabled": StatusDisabled,
}

Functions

func FileExists

func FileExists(fn string) bool

func Init

func Init(s Settings) (err error)

func Serve

func Serve(s Settings) (err error)

Types

type APIError

type APIError struct {
	Error string
}

type Account

type Account struct {
	DetailModel
	Exchange      string
	APIPublicKey  string
	APIPrivateKey string
	// contains filtered or unexported fields
}

type Asset

type Asset struct {
	ID     int
	Symbol string
	Name   string
}

type Broker

type Broker struct {
	DetailModel

	Name      string
	Pair      string
	MinWait   float64
	MaxWait   float64
	HighLimit float64
	LowLimit  float64
	Delta     float64
	Offset    float64
	Base      float64
	Quote     float64
	Fee       float64
	// contains filtered or unexported fields
}

type Checkpoint

type Checkpoint struct {
	ID        uint
	CreatedAt time.Time
	BrokerID  uint
	Price     float64
}

type Claims

type Claims struct {
	jwt.StandardClaims
	Role string
}

type Core

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

func (*Core) ParseToken

func (core *Core) ParseToken(tokenString string) (claims *Claims, err error)

type DetailModel

type DetailModel struct {
	ID        uint
	NodeID    uint
	CreatedAt time.Time `gorm:"index"`
	Status    uint
}

Details are inmutable, the newest detail is always the current one. Because of this references to tree nodes are stored in the detail struct.

type Detailer

type Detailer interface {
	// contains filtered or unexported methods
}

type ErrorPayload

type ErrorPayload struct {
	Status int
	Error  string
}

type Group

type Group struct {
	DetailModel
}

type LoginResp

type LoginResp struct {
	Success bool
	Message string
}

type Message

type Message struct {
	Type    string
	User    *Node
	Path    string
	Payload interface{}
	// contains filtered or unexported fields
}

type Node

type Node struct {
	gorm.Model
	DetailType uint
	Name       string `gorm:"UNIQUE_INDEX:unique_name_per_tnode"`
	ParentID   uint   `gorm:"UNIQUE_INDEX:unique_name_per_tnode"`

	Detail Detailer `gorm:"-:all"`
	// contains filtered or unexported fields
}

type Pocket

type Pocket struct {
	DetailModel
	Holdings map[Asset]float64
	// contains filtered or unexported fields
}

type Root

type Root struct {
	DetailModel
}

type Setting

type Setting struct {
	Name  string
	Value interface{}
}

type Settings

type Settings struct {
	LogLevel      string
	WorkDir       string
	HTTPAddr      string
	WSAddr        string
	DBPath        string
	JWTKeyPath    string
	DBKeyPath     string
	CLICookiePath string
}

func (*Settings) Init

func (s *Settings) Init()

type User

type User struct {
	DetailModel
	Email    string `gorm:"unique"`
	Role     string
	Password string
}

Jump to

Keyboard shortcuts

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