config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: Apache-2.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateConfig

func GenerateConfig() error

GenerateConfig started the interactive cli to generate config file

func HandleConfig

func HandleConfig(isProd bool, cb func(*Project) error) http.HandlerFunc

HandleConfig returns the handler to load the config via a REST endpoint

Types

type Auth

type Auth map[string]*AuthStub // The key here is the sign in method

Auth holds the mapping of the sign in method

type AuthStub

type AuthStub struct {
	Enabled bool   `json:"enabled" yaml:"enabled"`
	ID      string `json:"id" yaml:"id"`
	Secret  string `json:"secret" yaml:"secret"`
}

AuthStub holds the config at a single sign in level

type Config

type Config struct {
	Projects map[string]*Project `json:"projects" yaml:"projects"` // The key here is the project id
}

Config holds the entire configuration

type Crud

type Crud map[string]*CrudStub // The key here is the database type

Crud holds the mapping of database level configuration

type CrudStub

type CrudStub struct {
	Conn        string                `json:"conn" yaml:"conn"`
	Collections map[string]*TableRule `json:"collections" yaml:"collections"` // The key here is table name
	IsPrimary   bool                  `json:"isPrimary" yaml:"isPrimary"`
}

CrudStub holds the config at the database level

type FileRule

type FileRule struct {
	Prefix string           `json:"prefix" yaml:"prefix"`
	Rule   map[string]*Rule `json:"rule" yaml:"rule"` // The key can be create, read, delete
}

FileRule is the authorization object at the file rule level

type FileStore

type FileStore struct {
	Enabled   bool                 `json:"enabled" yaml:"enabled"`
	StoreType string               `json:"storeType" yaml:"storeType"`
	Conn      string               `json:"conn" yaml:"conn"`
	Rules     map[string]*FileRule `json:"rules" yaml:"rules"`
}

FileStore holds the config for the file store module

type FuncRules

type FuncRules map[string]map[string]*Rule // service -> function -> rule

FuncRules is the rules for the functions module

type Functions

type Functions struct {
	Enabled bool         `json:"enabled" yaml:"enabled"`
	Broker  utils.Broker `json:"broker" yaml:"broker"`
	Conn    string       `json:"conn" yaml:"conn"`
	Rules   FuncRules    `json:"rules" yaml:"rules"`
}

Functions holds the config for the functions module

type Modules

type Modules struct {
	Crud      Crud       `json:"crud" yaml:"crud"`
	Auth      Auth       `json:"auth" yaml:"auth"`
	Functions *Functions `json:"functions" yaml:"functions"`
	Realtime  *Realtime  `json:"realtime" yaml:"realtime"`
	FileStore *FileStore `json:"fileStore" yaml:"fileStore"`
	Static    *Static    `json:"static" yaml:"static"`
}

Modules holds the config of all the modules of that environment

type Project

type Project struct {
	ID      string   `json:"id" yaml:"id"`
	Secret  string   `json:"secret" yaml:"secret"`
	Modules *Modules `json:"modules" yaml:"modules"`
	SSL     *SSL     `json:"ssl" yaml:"ssl"`
}

Project holds the project level configuration

func LoadConfigFromFile

func LoadConfigFromFile(path string) (*Project, error)

LoadConfigFromFile loads the config from the provided file path

type Realtime

type Realtime struct {
	Enabled bool         `json:"enabled" yaml:"enabled"`
	Broker  utils.Broker `json:"broker" yaml:"broker"`
	Conn    string       `json:"conn" yaml:"conn"`
}

Realtime holds the config for the realtime module

type Rule

type Rule struct {
	Rule    string                 `json:"rule" yaml:"rule"`
	Eval    string                 `json:"eval" yaml:"eval"`
	Type    string                 `json:"type" yaml:"type"`
	F1      interface{}            `json:"f1" yaml:"f1"`
	F2      interface{}            `json:"f2" yaml:"f2"`
	Clauses []*Rule                `json:"clauses" yaml:"clauses"`
	DB      string                 `json:"db" yaml:"db"`
	Col     string                 `json:"col" yaml:"col"`
	Find    map[string]interface{} `json:"find" yaml:"find"`
	Service string                 `json:"service" yaml:"service"`
	Func    string                 `json:"func" yaml:"func"`
}

Rule is the authorisation object at the query level

type SSL

type SSL struct {
	Crt string `json:"crt" yaml:"crt"`
	Key string `json:"key" yaml:"key"`
}

SSL holds the certificate and key file locations

type Static

type Static struct {
	Enabled bool           `json:"enabled" yaml:"enabled"`
	Routes  []*StaticRoute `json:"routes" yaml:"routes"`
}

Static holds the config for the static files module

type StaticRoute

type StaticRoute struct {
	Path      string `json:"path" yaml:"path"`
	URLPrefix string `json:"prefix" yaml:"prefix"`
	Host      string `json:"host" yaml:"host"`
	Proxy     string `json:"proxy" yaml:"proxy"`
}

StaticRoute holds the config for each route

type TableRule

type TableRule struct {
	IsRealTimeEnabled bool             `json:"isRealtimeEnabled" yaml:"isRealtimeEnabled"`
	Rules             map[string]*Rule `json:"rules" yaml:"rules"` // The key here is query, insert, update or delete
}

TableRule contains the config at the collection level

Jump to

Keyboard shortcuts

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