globals

package
v0.0.0-...-4b144c9 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB *gorm.DB
)
View Source
var (
	LOG *zap.Logger
)

Functions

func DbCtx

func DbCtx(ctx context.Context, tx *gorm.DB) context.Context

func DbFromCtx

func DbFromCtx(ctx context.Context) *gorm.DB

func InitDatabase

func InitDatabase()

func InitLogging

func InitLogging() (_ *zap.Logger, err error)

func IsDev

func IsDev() bool

func IsProd

func IsProd() bool

func MustTokenUserCtx

func MustTokenUserCtx(c fiber.Ctx) context.Context

func SetTokenUser

func SetTokenUser(tokenUser *TokenUser, c fiber.Ctx)

func Transaction

func Transaction[T any](trans func(*gorm.DB) (*T, error)) (*T, error)

Types

type AppConfig

type AppConfig struct {
	Server *ServerConfig
	DB     *DBConfig
	Auth   *AuthenticationConfig
	Redis  *RedisConfig
}
var (
	CONF *AppConfig
)

func MustLoad

func MustLoad() *AppConfig

type AuthenticationClaims

type AuthenticationClaims struct {
	TokenUser
	jwt.RegisteredClaims
}

type AuthenticationConfig

type AuthenticationConfig struct {
	Jwt       *JwtConfig
	WhiteList []string `yaml:"whiteList"`
}

type ContextDBKey

type ContextDBKey struct{}

type CorsConfig

type CorsConfig struct {
	Enable  bool
	Origins []string
}

type DBConfig

type DBConfig struct {
	Host     string
	User     string
	Password string
	Database string
	Port     uint16
}

type JwtConfig

type JwtConfig struct {
	JwtExpireSec int64  `yaml:"jwtExpireSec"`
	JwtSecret    string `yaml:"jwtSecret"`
	JwtIssuer    string `yaml:"jwtIssuer"`
}

type RedisConfig

type RedisConfig struct {
	Host     string
	Port     uint16
	Db       int
	Password string
}

type ServerConfig

type ServerConfig struct {
	// Name       string
	Port       uint16
	PathPrefix string `yaml:"pathPrefix"`
	Cors       CorsConfig
}

type TokenUser

type TokenUser struct {
	UserId uint
}

func GetTokenUser

func GetTokenUser(c fiber.Ctx) (*TokenUser, error)

func MustTokenUser

func MustTokenUser(c fiber.Ctx) *TokenUser

func MustTokenUserFromCtx

func MustTokenUserFromCtx(c context.Context) *TokenUser

type TokenUserKey

type TokenUserKey struct{}

Jump to

Keyboard shortcuts

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