initializers

package
v0.0.0-...-15e17f2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB *gorm.DB // global connection to the DB

)

Functions

func ConnectDB

func ConnectDB(config *Config)

ConnectDB connects to the database and performs migrations.

func GetDB

func GetDB() *gorm.DB

GetDB returns a connection to the database

Types

type Config

type Config struct {
	DBHost         string `mapstructure:"POSTGRES_HOST"`
	DBUserName     string `mapstructure:"POSTGRES_USER"`
	DBUserPassword string `mapstructure:"POSTGRES_PASSWORD"`
	DBName         string `mapstructure:"POSTGRES_DB"`
	DBPort         string `mapstructure:"POSTGRES_PORT"`

	JwtSecret    string        `mapstructure:"JWT_SECRET"`
	JwtExpiresIn time.Duration `mapstructure:"JWT_EXPIRED_IN"`
	JwtMaxAge    int           `mapstructure:"JWT_MAXAGE"`

	ClientOrigin       string   `mapstructure:"CLIENT_ORIGIN"`
	CorsAllowedOrigins []string `mapstructure:"ALLOWED_ORIGINS"`

	KafkaBrokers         string `mapstructure:"KAFKA_BROKERS"`
	KafkaNumOfPartitions int    `mapstructure:"KAFKA_NUM_OF_PARTITIONS"`

	EnableWebsocket bool `mapstructure:"ENABLE_WEBSOCKET"`
}

func GetConfig

func GetConfig() *Config

func LoadConfig

func LoadConfig(path string) (*Config, error)

Jump to

Keyboard shortcuts

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