nhost

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DB_USER     = "postgres"
	DB_PASSWORD = "postgres"

	MINIO_USER     = "minioaccesskey123123"
	MINIO_PASSWORD = "minioaccesskey123123"
)

Variables

View Source
var (
	DOMAIN string
	API    string

	//  fetch current working directory
	NHOST_DIR string

	//  find user's home directory
	HOME string

	//  Nhost root directory for HOME
	ROOT string

	//  authentication file location
	AUTH_PATH string

	//  path for migrations
	MIGRATIONS_DIR string

	//  path for metadata
	METADATA_DIR string

	//  default Nhost database
	DATABASE string

	//  path for seeds
	SEEDS_DIR string

	//  path for .nhost
	DOT_NHOST_DIR string

	//  path for frontend
	WEB_DIR string

	//  path for API code
	API_DIR string

	//  path for email templates
	EMAILS_DIR string

	//  path for local git directory
	GIT_DIR string

	//  path for .env.development
	ENV_FILE string

	//  path for config.yaml file
	CONFIG_PATH string

	//  path for .gitignore file
	GITIGNORE string

	//  path for .nhost/nhost.yaml file
	INFO_PATH string

	//  path for express NPM modules
	NODE_MODULES_PATH string

	//  package repository to download latest release from
	REPOSITORY string

	//	mandatorily required locations
	LOCATIONS Required
)

Functions

func EnsureProjectNameFileExists added in v0.7.2

func EnsureProjectNameFileExists() error

func Env

func Env() ([]string, error)

func GetDockerComposeProjectName added in v0.7.1

func GetDockerComposeProjectName() (string, error)

func Init added in v0.5.9

func Init()

Initialize Nhost variables for runtime

func InitLocations added in v0.5.9

func InitLocations() error

func NewTemplatesInstaller added in v0.7.1

func NewTemplatesInstaller(logger logrus.FieldLogger) *templatesInstaller

func ParseEnvVarsFromConfig

func ParseEnvVarsFromConfig(payload map[interface{}]interface{}, prefix string) []string

func RunCmdAndCaptureStderrIfNotSetup added in v0.7.1

func RunCmdAndCaptureStderrIfNotSetup(cmd *exec.Cmd) error

func UpdateLocations added in v0.5.9

func UpdateLocations(old, new string)

Updates the directory paths in all variables TODO: refactor

Types

type App

type App struct {
	ID         string              `json:"id,omitempty"`
	Name       string              `json:"name,omitempty"`
	Subdomain  string              `json:"subdomain,omitempty"`
	Region     Region              `json:"region"`
	AppSecrets model.Secrets       `json:"appSecrets,omitempty"`
	Config     *model.ConfigConfig `json:"config"`
	Workspace  string              `json:"workspace,omitempty"`
}

func Info

func Info() (App, error)

type Asset

type Asset struct {
	URL                string `json:",omitempty"`
	Name               string `json:",omitempty"`
	ID                 string `json:",omitempty"`
	Label              string `json:",omitempty"`
	BrowserDownloadURL string `json:"browser_download_url,omitempty"`
	Size               int    `json:",omitempty"`
}

GitHub Release API Assets structure

type Authentication

type Authentication struct {
	Endpoints map[string]interface{} `yaml:",omitempty"`
	Providers map[string]interface{} `yaml:",omitempty"`
	Signin    map[string]interface{} `yaml:",omitempty"`
	Signup    map[string]interface{} `yaml:",omitempty"`
	Email     map[string]interface{} `yaml:",omitempty"`
	Tokens    map[string]interface{} `yaml:",omitempty"`
	Gravatar  map[string]interface{} `yaml:",omitempty"`
}

Nhost config.yaml authentication structure

type Configuration

type Configuration struct {
	MetadataDirectory string                      `yaml:"metadata_directory,omitempty"`
	Services          map[string]*Service         `yaml:",omitempty"`
	Auth              map[interface{}]interface{} `yaml:",omitempty"`
	Storage           map[interface{}]interface{} `yaml:",omitempty"`
	Version           int                         `yaml:",omitempty"`
	Sessions          map[string]Session          `yaml:",omitempty"`
}

Nhost config.yaml root structure

func GenerateConfig

func GenerateConfig(options App) Configuration

generates fresh config.yaml for /nhost dir

func GetConfiguration added in v0.7.1

func GetConfiguration() (*Configuration, error)

func (*Configuration) MarshalJSON

func (r *Configuration) MarshalJSON() ([]byte, error)

func (*Configuration) MarshalYAML

func (r *Configuration) MarshalYAML() ([]byte, error)

func (*Configuration) Save

func (config *Configuration) Save() error

type Credentials

type Credentials struct {
	ID    string `json:"id,omitempty"`
	Token string `json:"token,omitempty"`
}

Authentication credentials structure

func LoadCredentials

func LoadCredentials() (Credentials, error)

fetches saved credentials from auth file

type Domains

type Domains struct {
	Hasura string `json:"hasura_domain,omitempty"`
}

Nhost project domains

type EnvVar

type EnvVar struct {
	ID    string `json:"id,omitempty"`
	Name  string `json:"name,omitempty"`
	Value string `json:"devValue,omitempty"`
}

type Error

type Error struct {
	Code  string
	Email string
}

Error structure

type Information

type Information struct {
	ProjectID string `yaml:"project_id,omitempty"`
	ID        string `yaml:",omitempty"`
	Name      string `yaml:",omitempty"`
}

.nhost/nhost.yaml information

type Project

type Project struct {
	ID                          string                   `json:"id" yaml:"project_id"`
	UserID                      string                   `json:"user_id"`
	Team                        Team                     `json:",omitempty"`
	TeamID                      string                   `json:"team_id,omitempty"`
	Type                        string                   `json:",omitempty"`
	Name                        string                   `json:"name"`
	HasuraGQEVersion            string                   `json:"hasura_gqe_version,omitempty"`
	BackendVersion              string                   `json:"backend_version,omitempty"`
	HasuraGQEAdminSecret        string                   `json:"hasura_gqe_admin_secret,omitempty"`
	PostgresVersion             string                   `json:"postgres_version,omitempty"`
	HasuraGQECustomEnvVariables map[string]string        `json:"hasura_gqe_custom_env_variables,omitempty"`
	BackendUserFields           string                   `json:"backend_user_fields,omitempty"`
	HBPDefaultAllowedUserRoles  string                   `json:"hbp_DEFAULT_ALLOWED_USER_ROLES,omitempty"`
	HBPRegistrationCustomFields string                   `json:"hbp_REGISTRATION_CUSTOM_FIELDS,omitempty"`
	HBPAllowedUserRoles         string                   `json:"hbp_allowed_user_roles,omitempty"`
	ProjectDomains              Domains                  `json:"project_domain"`
	ProjectEnvVars              []map[string]interface{} `json:"project_env_vars,omitempty"`
}

Nhost project structure

func (*Project) MarshalJSON

func (r *Project) MarshalJSON() ([]byte, error)

func (*Project) MarshalYAML

func (r *Project) MarshalYAML() ([]byte, error)

type Region added in v0.8.20

type Region struct {
	AwsName string `json:"awsName"`
}

type Release

type Release struct {
	URL         string  `json:",omitempty"`
	Name        string  `json:",omitempty"`
	TagName     string  `json:"tag_name,omitempty"`
	Prerelease  bool    `json:",omitempty"`
	CreatedAt   string  `json:"created_at,omitempty"`
	PublishedAt string  `json:",omitempty"`
	Body        string  `json:",omitempty"`
	Assets      []Asset `json:",omitempty"`
}

GitHub Release API reponse structure

func GetReleases added in v0.5.7

func GetReleases() ([]Release, error)

Downloads the list of all releases from GitHub API

func SearchRelease added in v0.5.7

func SearchRelease(releases []Release, version string) (Release, error)

Seaches for required release from supplied list of releases, and returns it.

func (*Release) Asset

func (release *Release) Asset() Asset

fetches the required asset from release depending on OS and Architecture by matching download URL

func (*Release) Changes added in v0.5.7

func (r *Release) Changes(releases []Release) (string, error)

Compares and updates the changelog for specified release

func (*Release) MarshalJSON added in v0.5.7

func (r *Release) MarshalJSON() ([]byte, error)

type Required added in v0.5.9

type Required struct {
	Directories []*string
	Files       []*string
}

type Response

type Response struct {
	Project           Project `json:",omitempty"`
	User              User
	Error             Error
	Email             string `json:"email"`
	VerificationToken string `json:"verificationToken"`
	VerifiedToken     string `json:"token"`
}

Authentication validation response

type Server

type Server struct {
	ID          string
	Name        string
	CountryCode string
	City        string
}

Nhost servers structure

func Servers

func Servers() ([]Server, error)

fetches the list of Nhost production servers

type Service

type Service struct {
	Port    int         `yaml:",omitempty"`
	Version interface{} `yaml:",omitempty"`
	Image   string      `yaml:",omitempty"`
	//	AdminSecret    interface{}            `yaml:"admin_secret,omitempty"`
	Name           string                 `yaml:",omitempty"`
	Address        string                 `yaml:",omitempty"`
	ID             string                 `yaml:",omitempty"`
	Config         *container.Config      `yaml:",omitempty"`
	HostConfig     *container.HostConfig  `yaml:",omitempty"`
	HealthEndpoint string                 `yaml:"health_endpoint,omitempty"`
	Environment    map[string]interface{} `yaml:",omitempty"`

	//	If custom address is mentioned,
	//	do not launch the container
	NoContainer bool `yaml:",omitempty"`

	//  Channels are best thought of as queues (FIFO).
	//  Therefore you can't really skip around.
	//  We need a mutex to lock the service
	//  before updating it's channels.
	sync.Mutex `yaml:",omitempty"`
	Active     bool `yaml:",omitempty"`
}

Nhost config.yaml service structure

type Session

type Session struct {
	Command string
	Dir     string
	Log     bool
	Browser string
}

Session struct

type Team

type Team struct {
	Name     string    `json:",omitempty"`
	ID       string    `json:",omitempty"`
	Projects []Project `json:",omitempty"`
}

type TeamData

type TeamData struct {
	Team Team `json:",omitempty"`
}

Nhost individual team structure

type Template added in v0.7.1

type Template struct {
	Name        string
	Destination *string
	Path        string
	Repository  string
}

Template represents a structure for a template

type User

type User struct {
	ID               string            `json:"id,omitempty"`
	Name             string            `json:"displayName,omitempty"`
	WorkspaceMembers []WorkspaceMember `json:"workspaceMembers,omitempty"`
}

Nhost user structure

type Workspace

type Workspace struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	Apps []App  `json:"apps,omitempty"`
}

type WorkspaceMember

type WorkspaceMember struct {
	ID        string    `json:"id,omitempty"`
	Workspace Workspace `json:"workspace,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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