config

package
v0.0.0-...-82802e3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	AccessTokenLifeTime  time.Duration `env:"ACCESS_TOKEN_LIFETIME" envDefault:"720h" toml:"access_token_lifetime"`
	RefreshTokenLifeTime time.Duration `env:"REFRESH_TOKEN_LIFETIME" envDefault:"720h" toml:"refresh_token_lifetime"`
	PasswordDifficult    float64       `env:"MIN_PASSWORD_ENTROPY" toml:"password_difficult"`
	AuthTokenSize        int           `env:"AUTH_TOKEN_SIZE" toml:"auth_token_size"`
}

type Config

type Config struct {
	Postgres Postgres `toml:"postgres"`
	HTTPS    HTTPS    `toml:"https"`
	Server   Server   `toml:"server"`
	Test     Test     `toml:"-"`
	Auth     Auth     `toml:"auth"`
}

Config ...

func New

func New() *Config

New creates new config once and return singleton object every time when called.

func (*Config) ParseFromFile

func (c *Config) ParseFromFile(file string) error

ParseFromFile parses config from file.

File path must be absolute.

func (*Config) Valid

func (c *Config) Valid() (ok bool, err error)

Valid ...

type HTTPS

type HTTPS struct {
	CertFile     string   `env:"CERT_FILE"`
	KeyFile      string   `env:"KEY_FILE"`
	AllowedHosts []string `env:"ALLOWED_HOSTS" envSeparator:":"`
}

type Postgres

type Postgres struct {
	User     string `env:"POSTGRES_USER" toml:"user"`
	Password string `env:"POSTGRES_PASSWORD" toml:"password"`
	Port     uint   `env:"POSTGRES_PORT" toml:"port"`
	Addr     string `env:"POSTGRES_ADDR" toml:"host"`
	Name     string `env:"POSTGRES_NAME" toml:"name"`
	URI      string `env:"DB_URI"`
}

Postgres ...

func (*Postgres) SetDatabaseURI

func (p *Postgres) SetDatabaseURI()

SetDatabaseURI ...

type Roles

type Roles struct {
	Default model.Role `toml:"default_user"`
	Admin   model.Role `toml:"admin_user"`
}

type Server

type Server struct {
	Type               string `env:"SERVER_TYPE" toml:"type" valid:"in(grpc|http|https|GRPC|HTTP|HTTPS)" envDefault:"HTTP"`
	EnableHTTP         bool   `toml:"-"`
	EnableGRPC         bool   `toml:"-"`
	Salt               string `env:"ENCRYPT_SALT" valid:"required~use generated salt from the logs" toml:"salt"`
	SecretKey          string `env:"SECRET_KEY" valid:"required" toml:"secret_key"`
	IsDev              bool   `env:"IS_DEV" toml:"is_dev"`
	IsProd             bool   `env:"IS_PRODUCTION" toml:"is_prod"`
	Port               uint   `env:"BIND_PORT" toml:"port"`
	Addr               string `env:"BIND_ADDR" toml:"addr"`
	BaseURL            string `env:"BASE_URL" toml:"base_url"`
	InviteLinkTemplate string `env:"INVITE_LINK_TEMPLATE"`
}

Server is internal configuration of server.

type Test

type Test struct {
	DatabaseURI string `env:"TEST_DB_URI"`
	Enable      bool   `env:"TEST"`
}

Test is a configuration that is using in tests

Jump to

Keyboard shortcuts

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