model

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlanFree = iota
	PlanIdea
	PleanLaunch
	PlanTraction
	PlanGrowth
)
View Source
const (
	SystemID = "sb"

	MsgTypeError     = "error"
	MsgTypeOk        = "ok"
	MsgTypeEcho      = "echo"
	MsgTypeInit      = "init"
	MsgTypeAuth      = "auth"
	MsgTypeToken     = "token"
	MsgTypeJoin      = "join"
	MsgTypeJoined    = "joined"
	MsgTypePresence  = "presence"
	MsgTypeChanIn    = "chan_in"
	MsgTypeChanOut   = "chan_out"
	MsgTypeDBCreated = "db_created"
	MsgTypeDBUpdated = "db_updated"
	MsgTypeDBDeleted = "db_deleted"
)
View Source
const (
	TaskTypeFunction = "function"
	TaskTypeMessage  = "message"
)

Variables

View Source
var (
	HashSecret *jwt.HMACSHA
)

Functions

func CleanCollectionName

func CleanCollectionName(col string) string

func EncryptExternalLogins

func EncryptExternalLogins(tokens map[string]OAuthConfig) ([]byte, error)

Types

type Account

type Account struct {
	ID      string    `json:"id"`
	Email   string    `json:"email"`
	Created time.Time `json:"created"`
}

type Auth

type Auth struct {
	AccountID string `json:"accountId"`
	UserID    string `json:"userId"`
	Email     string `json:"email"`
	Role      int    `json:"role"`
	Token     string `json:"-"`
	Plan      int    `json:"-"`
}

Auth represents an authenticated user.

func (Auth) ReconstructToken

func (auth Auth) ReconstructToken() string

type Command

type Command struct {
	SID           string `json:"sid"`
	Type          string `json:"type"`
	Data          string `json:"data"`
	Channel       string `json:"channel"`
	Token         string `json:"token"`
	IsSystemEvent bool   `json:"-"`
}

func (Command) IsDBEvent

func (msg Command) IsDBEvent() bool

type DatabaseConfig

type DatabaseConfig struct {
	ID               string    `json:"id"`
	TenantID         string    `json:"customerId"`
	Name             string    `json:"name"`
	AllowedDomain    []string  `json:"whitelist"`
	IsActive         bool      `json:"-"`
	MonthlySentEmail int       `json:"-"`
	Created          time.Time `json:"created"`
}

type ExecData

type ExecData struct {
	ID           string        `json:"id"`
	AccountID    string        `json:"accountId"`
	FunctionName string        `json:"name"`
	TriggerTopic string        `json:"trigger"`
	Code         string        `json:"code"`
	Version      int           `json:"version"`
	LastUpdated  time.Time     `json:"lastUpdated"`
	LastRun      time.Time     `json:"lastRun"`
	History      []ExecHistory `json:"history"`
}

ExecData represents a server-side function with its name, code and execution history

type ExecHistory

type ExecHistory struct {
	ID         string    `json:"id"`
	FunctionID string    `json:"functionId"`
	Version    int       `json:"version"`
	Started    time.Time `json:"started"`
	Completed  time.Time `json:"completed"`
	Success    bool      `json:"success"`
	Output     []string  `json:"output"`
}

ExecHistory represents a function run ending result

type File

type File struct {
	ID        string    `json:"id"`
	AccountID string    `json:"accountId"`
	Key       string    `json:"key"`
	URL       string    `json:"url"`
	Size      int64     `json:"size"`
	Uploaded  time.Time `json:"uploaded"`
}

type JWTPayload

type JWTPayload struct {
	jwt.Payload
	Token string `json:"token,omitempty"`
}

JWTPayload contains the current user token

type ListParams

type ListParams struct {
	Page           int64
	Size           int64
	SortBy         string
	SortDescending bool
}

type Login

type Login struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type MetaMessage

type MetaMessage struct {
	Data    string `json:"data"`
	Channel string `json:"channel"`
}

type OAuthConfig

type OAuthConfig struct {
	ConsumerKey    string
	ConsumerSecret string
}

type PagedResult

type PagedResult struct {
	Page    int64                    `json:"page"`
	Size    int64                    `json:"size"`
	Total   int64                    `json:"total"`
	Results []map[string]interface{} `json:"results"`
}

type Task

type Task struct {
	ID       string      `json:"id"`
	Name     string      `json:"name"`
	Type     string      ` json:"type"`
	Value    string      ` json:"value"`
	Meta     interface{} ` json:"meta"`
	Interval string      ` json:"interval"`
	LastRun  time.Time   ` json:"last"`

	BaseName string `json:"base"`
}

type Tenant

type Tenant struct {
	ID               string    `bson:"_id" json:"id"`
	Email            string    `bson:"email" json:"email"`
	StripeID         string    `bson:"stripeId" json:"stripeId"`
	SubscriptionID   string    `bson:"subId" json:"subId"`
	Plan             int       `json:"plan"`
	IsActive         bool      `bson:"active" json:"-"`
	MonthlyEmailSent int       `bson:"mes" json:"-"`
	Created          time.Time `bson:"created" json:"created"`
	ExternalLogins   []byte    `json:"-"`
}

func (*Tenant) GetExternalLogins

func (cus *Tenant) GetExternalLogins() (map[string]OAuthConfig, error)

func (*Tenant) GetProvider

func (cus *Tenant) GetProvider(provider string) (cfg OAuthConfig, ok bool)

type UploadFileData

type UploadFileData struct {
	FileKey string
	File    io.ReadSeeker
}

type User

type User struct {
	ID        string    `json:"id"`
	AccountID string    `json:"accountId"`
	Token     string    `json:"token"`
	Email     string    `json:"email"`
	Password  string    `json:"-"`
	Role      int       `json:"role"`
	ResetCode string    `json:"-"`
	Created   time.Time `json:"created"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳