config

package
v0.0.0-...-afa0789 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const NAMESPACE = "LOGISTICS_APP"

Variables

This section is empty.

Functions

func InitMySQLDatabase

func InitMySQLDatabase(cfg Configuration) *gorm.DB

Types

type App

type App struct {
	Environment  string   `envconfig:"ENVIRONMENT"`
	EnableCors   bool     `envconfig:"ENABLE_CORS" default:"false"`
	AllowOrigins []string `envconfig:"ALLOWORIGINS" default:"*"`
}

type Configuration

type Configuration struct {
	LoggerLevel string   `envconfig:"LOG_LEVEL" default:"error"`
	Server      Server   `envconfig:"SERVER"`
	Database    Database `envconfig:"DATABASE"`
	App         App      `envconfig:"APP"`

	MigrateConfig MigrateConfig `envconfig:"MIGRATE"`

	JWT JWTConfig `envconfig:"JWT"`
}
var (
	AppConfig Configuration
)

func Get

func Get() Configuration

type Database

type Database struct {
	Mysql    Mysql `envconfig:"MYSQL"`
	LogLevel int   `envconfig:"LOG_LEVEL" default:"4"`
}

type JWTConfig

type JWTConfig struct {
	Key                string `envconfig:"KEY"`
	AccessTokenExpiry  int    `envconfig:"ACCESS_TOKEN_EXPIRY" default:"86400"`   // default 1d
	RefreshTokenExpiry int    `envconfig:"REFRESH_TOKEN_EXPIRY" default:"604800"` // default 7d
}

type MigrateConfig

type MigrateConfig struct {
	AutoMigrate bool `envconfig:"AUTO" default:"false"`
}

type Mysql

type Mysql struct {
	Host     string `envconfig:"HOST"`
	Port     int    `envconfig:"PORT"`
	Username string `envconfig:"USERNAME"`
	Password string `envconfig:"PASSWORD"`
	DBName   string `envconfig:"DBNAME"`
}

func (Mysql) DSN

func (m Mysql) DSN() string

type Server

type Server struct {
	TZ   string `envconfig:"TZ" default:"UTC"`
	Host string `envconfig:"HOST" default:"0.0.0.0"`
	Port int    `envconfig:"PORT" default:"8080"`
}

func (Server) Address

func (s Server) Address() string

Jump to

Keyboard shortcuts

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