config

package
v0.0.0-...-4a192ad Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP_STAGE_PROD = iota
	APP_STAGE_TEST = iota
	APP_STAGE_DEV  = iota
)

Variables

View Source
var VarCannotBeEmpty = errors.New("Variable cannot be empty")

Functions

func GetSmtpCfgFromEnv

func GetSmtpCfgFromEnv() (SMTPConfig, EnvErr)

func StageToString

func StageToString(stage int) string

Used for logging

Types

type AppConfig

type AppConfig struct {
	AppStage int // Default production

	Address string // Default "127.0.0.1"
	Domain  string // Default: ""
	// Default 80 if TLS disabled and 433 if enabled
	HTTPPort  int
	ApiPrefix string // Default "/"

	// TLS config
	PathToCert string // .crt || .pem file
	PathToKey  string // .key file
	// necessary to be true if stage is production
	EnableTLS bool

	PostgresURL       string
	PgMigrationConfig MigrationConfig

	RedisConfig *redis.Options

	SMTPConfig SMTPConfig
}

type EnvErr

type EnvErr = errorsx.CustomErr[EnvErrInfo]

func GetPgUrlFromEnv

func GetPgUrlFromEnv() (string, EnvErr)

func GetRedisOptionsFromEnv

func GetRedisOptionsFromEnv() (*redis.Options, EnvErr)

type EnvErrInfo

type EnvErrInfo struct {
	VarName string
}

type MigrationConfig

type MigrationConfig struct {
	MigrationsPath string
	VersionLimit   int
	Drop           bool
}

type SMTPConfig

type SMTPConfig struct {
	// From is the address from which server sends e-mails
	From         string
	SMTPServer   string // smtp.google.com:587
	SMTPPassword string
}

Jump to

Keyboard shortcuts

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