utils

package
v0.0.0-...-3c27b1e Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(password, hashedPassword string) error

func ErrorResponse

func ErrorResponse(err error) gin.H
func GenLink(frontend string, groupID string, inviterID string) string

func HashPassword

func HashPassword(password string) (string, error)

func MigrateDB

func MigrateDB(config Config) error

func NullInt64

func NullInt64(i int64) sql.NullInt64

func NullString

func NullString(s string) sql.NullString

func RandomEmail

func RandomEmail() string

func RandomInt

func RandomInt(min, max int64) int64

func RandomName

func RandomName() string

func RandomString

func RandomString(n int) string

func ResponseWithMessage

func ResponseWithMessage(message string) gin.H

func StringFromNull

func StringFromNull(n sql.NullString) string

func SuccessResponse

func SuccessResponse() gin.H

Types

type Config

type Config struct {
	Env                     string `mapstructure:"ENV"`
	DBDriver                string `mapstructure:"DB_DRIVER"`
	DBUrl                   string `mapstructure:"DATABASE_URL"`
	Host                    string `mapstructure:"HOST"`
	Port                    int    `mapstructure:"PORT"`
	ServerAddress           string `mapstructure:"SERVER_ADDRESS"`
	FrontendAddress         string `mapstructure:"FRONTEND_ADDRESS"`
	JwtSecretKey            string `mapstructure:"JWT_SECRET_KEY"`
	AccessTokenExpiredTime  int32  `mapstructure:"ACCESS_TOKEN_EXPIRED_TIME"`
	RefreshTokenExpiredTime int32  `mapstructure:"REFRESH_TOKEN_EXPIRED_TIME"`

	FBKey    string `mapstructure:"FB_KEY"`
	FBSecret string `mapstructure:"FB_SECRET"`
	GGKey    string `mapstructure:"GLE_KEY"`
	GGSecret string `mapstructure:"GLE_SECRET"`

	SendgridApiKey string `mapstructure:"SENDGRID_API_KEY"`
	SendgridEmail  string `mapstructure:"SENDGRID_EMAIL"`

	CloudinaryUrl          string `mapstructure:"CLOUDINARY_URL"`
	CloudinaryUploadFolder string `mapstructure:"CLOUDINARY_UPLOAD_FOLDER"`
}

func LoadConfig

func LoadConfig(path string) (config Config, err error)

type JwtWrapper

type JwtWrapper struct {
	SecretKey string
	Issuer    string
}

func (*JwtWrapper) GenerateToken

func (w *JwtWrapper) GenerateToken(user entities.User, expirationHours int32) (signedToken string, err error)

func (*JwtWrapper) ValidateToken

func (w *JwtWrapper) ValidateToken(signedToken string) (claims *jwtClaims, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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