utils

package
v0.0.0-...-bf6616c Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDockerTestContainer

func CreateDockerTestContainer() (*sql.DB, *dockertest.Pool, *dockertest.Resource, error)

func GenerateToken

func GenerateToken(expire time.Duration, userID int32) (string, error)

GenerateToken return paseto token

func GetEnv

func GetEnv(key, fallback string) string

func GetEnvForTesting

func GetEnvForTesting()

func GetFilePath

func GetFilePath(elem ...string) (string, error)

func MigrateDB

func MigrateDB(db *sql.DB, sourceURL string) error

func SeedCategory

func SeedCategory(db *sql.DB) error

func SeedDataFromSQL

func SeedDataFromSQL(db *sql.DB, sqlLocation string) error

func SeedMatchCategory

func SeedMatchCategory(db *sql.DB) error

func SeedUsers

func SeedUsers(db *sql.DB) error

func VerifyToken

func VerifyToken(token string) (*paseto.Token, error)

VerifyToken Validate token and return nil if it successes

Types

type Filter

type Filter struct {
	Page     int `form:"page,default=1" binding:"min=1,max=1000"`
	PageSize int `form:"page_size,default=10" binding:"min=1,max=50"`
}

func (*Filter) Limit

func (f *Filter) Limit() int64

func (*Filter) Offset

func (f *Filter) Offset() int64

type MetaData

type MetaData struct {
	CurrentPage  int `json:"current_page"`
	PageSize     int `json:"page_size"`
	LastPage     int `json:"last_page"`
	TotalRecords int `json:"total_records"`
}

func GetMetaData

func GetMetaData(totalRec, page, pageSize int) MetaData

Jump to

Keyboard shortcuts

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