config

package
v0.0.0-...-05b3b51 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 5 Imported by: 0

README

Config module

Includes local environment variables for the project.
Includes .env parser and config singleton for ease of use.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Domain   string         `json:"domain"`
	Port     int            `json:"port"`
	Env      string         `json:"env"`
	Pepper   string         `json:"pepper"`
	ServMail string         `json:"service_email"`
	ServPass string         `json:"service_password"`
	HMACKey  string         `json:"hmac_key"`
	Database PostgresConfig `json:"database"`

	Redis RedisConfig `json:"redis"`
	JWT   JWTConfig   `json:"jwt"`

	Google   SocialProviderConfig `json:"google"`
	Facebook SocialProviderConfig `json:"facebook"`
}

Config parameters

func GetInstance

func GetInstance() *Config

GetInstance Returns config singleton object,

  • if not initialized: returns after initialization

func LoadConfig

func LoadConfig(file string) *Config

LoadConfig returns config for the app

*Takes config filename as a argument
*If empty string is passed, uses default file

func (*Config) IsProd

func (c *Config) IsProd() bool

IsProd returns true if current environment is production

type JWTConfig

type JWTConfig struct {
	AccessSecret  string        `json:"access_secret"`
	RefreshSecret string        `json:"refresh_secret"`
	AccessExp     time.Duration `json:"access_exp"`
	RefreshExp    time.Duration `json:"refresh_exp"`
}

JWTConfig secrets

type OtacConfig

type OtacConfig struct {
	EntryPrefix string `json:"otac_prefix"` // Prefix of otac key(prefix+email) in redis
	Expires     int64  `json:"otac_expire"` // Time before expiration
}

OtacConfig parameters

type PostgresConfig

type PostgresConfig struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Password string `json:"password"`
	Name     string `json:"name"`
}

PostgresConfig parameters

func (*PostgresConfig) DBConnectionInfo

func (c *PostgresConfig) DBConnectionInfo() string

DBConnectionInfo returns database connection info

func (PostgresConfig) Dialect

func (PostgresConfig) Dialect() string

Dialect returns config dialect

type RedisConfig

type RedisConfig struct {
	Host string     `json:"host"`
	Port int        `json:"port"`
	OTAC OtacConfig `json:"otac"`
}

RedisConfig parameters

type SocialProviderConfig

type SocialProviderConfig struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

Google oauth config

Jump to

Keyboard shortcuts

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