lib

package
v0.0.0-...-52b800c Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Command

type Command interface {
	// Short returns string about short description of the command
	// the string is shown in help screen of cobra command
	Short() string

	// Setup is used to setup flags or pre-run steps for the command.
	//
	// For example,
	//  cmd.Flags().IntVarP(&r.num, "num", "n", 5, "description")
	//
	Setup(cmd *cobra.Command)

	// Run runs the command runner
	// run returns command runner which is a function with dependency
	// injected arguments.
	//
	// For example,
	//  Command{
	//   Run: func(l *lib.Logger) {
	// 	   l.Info("i am working")
	// 	 },
	//  }
	//
	Run() CommandRunner
}

Command interface is used to implement sub-commands in the system.

type CommandRunner

type CommandRunner any

type Env

type Env struct {
	Port        string `mapstructure:"PORT"`
	Environment string `mapstructure:"ENVIRONMENT"`
	LogOutput   string `mapstructure:"LOG_OUTPUT"`
	LogLevel    string `mapstructure:"LOG_LEVEL"`

	DatabaseType string `mapstructure:"DATABASE_TYPE"`
	DatabaseUrl  string `mapstructure:"DATABASE_URL"`

	MaxMultipartMemory   int64         `mapstructure:"MAX_MULTIPART_MEMORY"`
	JWTAccessSecret      string        `mapstructure:"JWT_ACCESS_SECRET"`
	JWTRefreshSecret     string        `mapstructure:"JWT_REFRESH_SECRET"`
	AccessTokenDuration  time.Duration `mapstructure:"ACCESS_TOKEN_DURATION"`
	RefreshTokenDuration time.Duration `mapstructure:"REFRESH_TOKEN_DURATION"`

	AWSAccessKeyID     string `mapstructure:"AWS_ACCESS_KEY_ID"`
	AWSSecretAccessKey string `mapstructure:"AWS_SECRET_ACCESS_KEY"`
	AWSRegion          string `mapstructure:"AWS_REGION"`
	AWSS3Bucket        string `mapstructure:"AWS_S3_BUCKET"`

	TimeZone      string `mapstructure:"TIMEZONE"`
	AdminEmail    string `mapstructure:"ADMIN_EMAIL"`
	AdminPassword string `mapstructure:"ADMIN_PASSWORD"`
}

func GetEnv

func GetEnv() *Env

type FiberLogger

type FiberLogger struct {
	*Logger
}

FiberLogger logger for fiber framework [subbed from main logger]

func (FiberLogger) Write

func (l FiberLogger) Write(p []byte) (n int, err error)

Writer interface implementation for fiber-framework

type FxLogger

type FxLogger struct {
	*Logger
}

FxLogger logger for go-fx [subbed from main logger]

func (FxLogger) LogEvent

func (l FxLogger) LogEvent(event fxevent.Event)

func (FxLogger) Printf

func (l FxLogger) Printf(str string, args ...any)

Printf prints go-fx logs

type GormLogger

type GormLogger struct {
	*Logger
	gormlogger.Config
	// contains filtered or unexported fields
}

GormLogger logger for gorm logging [subbed from main logger]

func (GormLogger) Error

func (l GormLogger) Error(_ context.Context, str string, args ...any)

Error prints error messages

func (GormLogger) Info

func (l GormLogger) Info(_ context.Context, str string, args ...any)

Info prints info

func (GormLogger) LogMode

LogMode set log mode

func (GormLogger) Trace

func (l GormLogger) Trace(_ context.Context, begin time.Time, fc func() (string, int64), err error)

Trace prints trace messages

func (GormLogger) Warn

func (l GormLogger) Warn(_ context.Context, str string, args ...any)

Warn prints warn messages

type Logger

type Logger struct {
	*zap.SugaredLogger
}

Logger structure

func GetLogger

func GetLogger() *Logger

GetLogger gets the global instance of the logger

func (Logger) GetFiberLogger

func (l Logger) GetFiberLogger() io.Writer

GetFiberLogger gets logger for fiber framework debugging

func (Logger) GetFxLogger

func (l Logger) GetFxLogger() fxevent.Logger

GetFxLogger gets logger for go-fx

func (Logger) GetGormLogger

func (l Logger) GetGormLogger() gormlogger.Interface

GetGormLogger build gorm logger from zap logger (sub-logger)

type ModelBase

type ModelBase struct {
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt"`
	DeletedAt gorm.DeletedAt `json:"deletedAt" gorm:"index"`
	ID        uint           `json:"id" gorm:"primarykey"`
}

Jump to

Keyboard shortcuts

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