config

package
v0.0.0-...-9fa777b Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config allows to build config for application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PostgresConnString string `env:"POSTGRES_URL"`
	MongoConnString    string `env:"MONGO_URL"`
	RedisCfg           RedisCfg
	JwtCfg             JwtCfg
	RefreshTokenCfg    RefreshTokenCfg
}

Config contains necessary application configuration

func Build

func Build() (Config, error)

Build constructs new Config based on environment variables

type JwtCfg

type JwtCfg struct {
	SigningMethod jwt.SigningMethod
	Issuer        string             `env:"AUTH_JWT_ISSUER" envDefault:"customers-api"`
	TimeToLive    time.Duration      `env:"AUTH_JWT_TIME_TO_LIVE" envDefault:"10m"`
	PrivateKey    ed25519.PrivateKey `env:"AUTH_JWT_PRIVATE_KEY_FILE"`
	PublicKey     ed25519.PublicKey  `env:"AUTH_JWT_PUBLIC_KEY_FILE"`
}

JwtCfg contains config for jwt

type RedisCfg

type RedisCfg struct {
	Addr       string `env:"REDIS_ADDR"`
	Password   string `env:"REDIS_PASSWORD"`
	DB         int    `env:"REDIS_DB" envDefault:"0"`
	MaxRetries int    `env:"REDIS_MAX_RETRIES" envDefault:"3"`
	PoolSize   int    `env:"REDIS_POOL_SIZE" envDefault:"50"`
}

RedisCfg contains config for redis

type RefreshTokenCfg

type RefreshTokenCfg struct {
	MaxCount   int           `env:"AUTH_REFRESH_TOKEN_MAX_COUNT" envDefault:"5"`
	TimeToLive time.Duration `env:"AUTH_REFRESH_TOKEN_TIME_TO_LIVE" envDefault:"720h"`
}

RefreshTokenCfg contains config for refresh token

Jump to

Keyboard shortcuts

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