util

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//	Common Error Codes
	WarnDockerNotFound  = "Please start docker and re-run `nhost`"
	ErrDockerNotFound   = "Docker not running"
	ErrServicesNotFound = "No services found currently running for this app"

	//	Common Information Codes
	InfoDockerDownload  = "Download docker from: https://www.docker.com/products/docker-desktop"
	InfoServicesRunning = "Start your app with `nhost dev`"
)
View Source
const (
	API_VERSION = "v1"

	//  initiaze webhook-secret for Hasura Authentication
	WEBHOOK_SECRET = "nhost-webhook-secret"

	//  initiaze admin-secret for Hasura Authentication
	ADMIN_SECRET = "nhost-admin-secret"
)

Variables

View Source
var (

	//  Initiaze JWT key for Hasura Authentication
	JWT_KEY = generateRandomKey(32)

	//	Map of environment specific variables generated dynamically on runtime.
	RUNTIME_VARS = map[string]interface{}{
		"HASURA_GRAPHQL_JWT_SECRET":   fmt.Sprintf(`{"type":"HS256", "key": "%v"}`, JWT_KEY),
		"NHOST_JWT_SECRET":            fmt.Sprintf(`{"type":"HS256", "key": "%v"}`, JWT_KEY),
		"HASURA_GRAPHQL_ADMIN_SECRET": ADMIN_SECRET,
		"NHOST_ADMIN_SECRET":          ADMIN_SECRET,
		"NHOST_WEBHOOK_SECRET":        WEBHOOK_SECRET,
	}
)
View Source
var (
	WORKING_DIR, _ = os.Getwd()
)

Functions

func Contains

func Contains(s []string, e string) bool

check whether source array contains value or not

func DeleteAllPaths

func DeleteAllPaths(path string) error

deletes all the paths leading to the given file/folder and unlink from filesystem

func DeletePath

func DeletePath(path string) error

deletes the given file/folder path and unlink from filesystem

func GetLocalhost added in v0.5.5

func GetLocalhost() string

Returns preferred local address value for accessing resources throughout docker containers, depending on the Operating System.

For Mac and Windows, the address value is "host.docker.internal". And for Linux, we are using the Outbound IP of host machine.

func MapToStringArray added in v0.5.5

func MapToStringArray(payload map[string]interface{}) []string

Wraps given map into string array

func PathExists

func PathExists(filePath string) bool

validates whether a given folder/file path exists or not

func Rel

func Rel(path string) string

Returns path relative to Nhost current working directory

func RuntimeVars added in v0.5.5

func RuntimeVars(port string, networkBased bool) map[string]interface{}

Augments default runtime variables, with dynamically generated ones, specific to the environment. For example: Backend URL with environment port.

If the additional `networkBased` flag is true, it makes sure to use that localhost address value, which can be accessed by docker across host network.

This is because docker requires different local addresses, depending on the host operating system.

Types

This section is empty.

Jump to

Keyboard shortcuts

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