config

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 10 Imported by: 21

Documentation

Overview

Package config is responsible for reading all environment variables and set up the base configuration for a functional application

Index

Constants

View Source
const Activated string = "yes"

Activated - "yes" keyword to activate a service

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Database   DatabaseConfig
	EmailConf  EmailConfig
	Logger     LoggerConfig
	Server     ServerConfig
	Security   SecurityConfig
	ViewConfig ViewConfig
}

Configuration - server and db configuration variables

func Config

func Config() *Configuration

Config - load all the configurations

func GetConfig added in v1.6.1

func GetConfig() *Configuration

GetConfig - return all the config variables

type DatabaseConfig

type DatabaseConfig struct {
	// relational database
	RDBMS RDBMS

	// redis database
	REDIS REDIS

	// mongo database
	MongoDB MongoDB
}

DatabaseConfig - all database variables

type EmailConfig added in v1.6.1

type EmailConfig struct {
	Activate     string
	Provider     string
	APIToken     string
	AddrFrom     string
	TrackOpens   bool
	TrackLinks   string
	DeliveryType string

	// for templated email
	EmailVerificationTemplateID int64
	PasswordRecoverTemplateID   int64
	EmailVerificationCodeLength uint64
	PasswordRecoverCodeLength   uint64
	EmailVerificationTag        string
	PasswordRecoverTag          string
	HTMLModel                   string
	EmailVerifyValidityPeriod   uint64 // in seconds
	PassRecoverValidityPeriod   uint64 // in seconds
}

EmailConfig - for external email services

type LoggerConfig added in v1.2.4

type LoggerConfig struct {
	Activate  string
	SentryDsn string
}

LoggerConfig ...

type MongoDB added in v1.4.3

type MongoDB struct {
	Activate string
	Env      struct {
		AppName  string
		URI      string
		PoolSize uint64
		PoolMon  string
		ConnTTL  int
	}
}

MongoDB - mongo database variables

type RDBMS added in v1.4.3

type RDBMS struct {
	Activate string
	Env      struct {
		Driver   string
		Host     string
		Port     string
		TimeZone string
	}
	Access struct {
		DbName string
		User   string
		Pass   string
	}
	Ssl struct {
		Sslmode string
	}
	Conn struct {
		MaxIdleConns    int
		MaxOpenConns    int
		ConnMaxLifetime time.Duration
	}
	Log struct {
		LogLevel int
	}
}

RDBMS - relational database variables

type REDIS added in v1.4.3

type REDIS struct {
	Activate string
	Env      struct {
		Host string
		Port string
	}
	Conn struct {
		PoolSize int
		ConnTTL  int
	}
}

REDIS - redis database variables

type SecurityConfig added in v1.3.0

type SecurityConfig struct {
	UserPassMinLength int

	MustBasicAuth string
	BasicAuth     struct {
		Username string
		Password string
	}

	MustJWT string
	JWT     middleware.JWTParameters

	MustHash string
	HashPass lib.HashPassConfig

	VerifyEmail bool
	RecoverPass bool

	MustFW   string
	Firewall struct {
		ListType string
		IP       string
	}

	MustCORS string
	CORS     []middleware.CORSPolicy

	TrustedPlatform string

	Must2FA string
	TwoFA   struct {
		Issuer string
		Crypto crypto.Hash
		Digits int

		Status Status2FA
		PathQR string
	}
}

SecurityConfig ...

type ServerConfig

type ServerConfig struct {
	ServerPort string // public port of server
	ServerEnv  string
}

ServerConfig ...

type Status2FA added in v1.6.1

type Status2FA struct {
	Verified string
	On       string
	Off      string
	Invalid  string
}

Status2FA - user's 2FA statuses

type ViewConfig added in v1.5.0

type ViewConfig struct {
	Activate  string
	Directory string
}

ViewConfig - HTML renderer

Jump to

Keyboard shortcuts

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