utils

package
v0.0.0-...-fea6390 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(username string, duration time.Duration, secret string) (uuid.UUID, string, pgtype.Timestamptz, error)

func GrpcLogger

func GrpcLogger(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error)

func HashPassword

func HashPassword(password string) (string, error)

func HttpLogger

func HttpLogger(handler http.Handler) http.Handler

func IsPasswordValid

func IsPasswordValid(password, hashedPassword string) bool

func ValidateEmail

func ValidateEmail(value string) error

func ValidateEmailId

func ValidateEmailId(value int64) error

func ValidateFullName

func ValidateFullName(value string) error

func ValidatePassword

func ValidatePassword(value string) error

func ValidateSecretCode

func ValidateSecretCode(value string) error

func ValidateString

func ValidateString(value string, minLength int, maxLength int) error

func ValidateUsername

func ValidateUsername(value string) error

func VerifyToken

func VerifyToken(token, secret string) (uuid.UUID, string, error)

Types

type Config

type Config struct {
	Env                   string        `mapstructure:"Env"`
	DBDriver              string        `mapstructure:"DB_DRIVER"`
	DBSource              string        `mapstructure:"DB_SOURCE"`
	DBMigrationURL        string        `mapstructure:"DB_MIGRATION_URL"`
	HTTP_Port             string        `mapstructure:"HTTP_PORT"`
	GRPC_Port             string        `mapstructure:"GRPC_PORT"`
	Redis_Port            string        `mapstructure:"REDIS_PORT"`
	Secret                string        `mapstructure:"SECRET"`
	TokenDuration         time.Duration `mapstructure:"TOKEN_DURATION"`
	RefereshTokenDuration time.Duration `mapstructure:"REFRESH_TOKEN_DURATION"`
	EmailSenderName       string        `mapstructure:"EMAIL_SENDER_NAME"`
	EmailSenderAddress    string        `mapstructure:"EMAIL_SENDER_ADDRESS"`
	EmailSenderPassword   string        `mapstructure:"EMAIL_SENDER_PASSWORD"`
}

func LoadConfig

func LoadConfig() (config Config, err error)

type EmailSender

type EmailSender interface {
	SendEmail(subject string, content string, to []string, cc []string, bcc []string, attachFiles []string) error
}

func NewGmailSender

func NewGmailSender(name string, fromEmailAddress string, fromEmailPassword string) EmailSender

type GmailSender

type GmailSender struct {
	// contains filtered or unexported fields
}

func (*GmailSender) SendEmail

func (sender *GmailSender) SendEmail(subject string, content string, to []string, cc []string, bcc []string, attachFiles []string) error

type ResponseRecorder

type ResponseRecorder struct {
	http.ResponseWriter
	StatusCode int
	Body       []byte
}

func (*ResponseRecorder) Write

func (rec *ResponseRecorder) Write(body []byte) (int, error)

func (*ResponseRecorder) WriteHeader

func (rec *ResponseRecorder) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

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