app

package
v0.0.0-...-9367810 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	APP_VERSION    = "22.02.041727"
	APP_ENV        = "production"
	APP_PORT       = "4004"
	IS_MAIN_SERVER = false // set to true to run migration, seed and task scheduling

	CRYPTO_KEY = "3025ad23c43d4ef68a24d4f36cee560b"

	DB_DRIVER            = "postgres"
	DB_HOST              = "127.0.0.1"
	DB_PORT              = 5432
	DB_DATABASE          = "grest-dev"
	DB_USERNAME          = "postgres"
	DB_PASSWORD          = "secret"
	DB_MAX_OPEN_CONNS    = 25
	DB_MAX_IDLE_CONNS    = 25
	DB_CONN_MAX_LIFETIME = time.Hour // on .env = "1h". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
	DB_IS_DEBUG          = false

	REDIS_HOST     = "127.0.0.1"
	REDIS_PORT     = "6379"
	REDIS_CACHE_DB = 0
	REDIS_USERNAME = ""
	REDIS_PASSWORD = ""

	FS_DRIVER      = "s3"
	FS_END_POINT   = "s3.amazonaws.com"
	FS_PORT        = 443
	FS_REGION      = "ap-southeast-1"
	FS_BUCKET_NAME = "grest-dev"
	FS_ACCESS_KEY  = ""
	FS_SECRET_KEY  = ""

	TELEGRAM_ALERT_TOKEN      = ""
	TELEGRAM_ALERT_CHANNEL_ID = ""
)

default config

Functions

func ConnectDB

func ConnectDB(connName string, c db.Config) error

func ErrorHandler

func ErrorHandler(c *fiber.Ctx, err error) error

func GetTrace

func GetTrace(skip int) map[string]string

func IsValid

func IsValid(v interface{}, tag string) bool

func NewApp

func NewApp(cfg ...grest.App) *grest.App

func NewErrorHandler

func NewErrorHandler(c *fiber.Ctx, statusCode int, message string, detail ...interface{}) error

func ParseQuery

func ParseQuery(c *fiber.Ctx) url.Values

func RemoveExpiredToken

func RemoveExpiredToken()

func SendAlert

func SendAlert(c *fiber.Ctx, message string, trace map[string]string)

func Validate

func Validate(lang string, v interface{}) error

Types

type Action

type Action struct {
	Method   string
	EndPoint string
}

type AnyTime

type AnyTime struct{}

func (AnyTime) Match

func (a AnyTime) Match(v driver.Value) bool

Match satisfies sqlmock.Argument interface

type Ctx

type Ctx struct {
	Lang       string
	Action     Action
	User       User
	IsTest     bool
	IsPrintSQL bool
	MockDB     sqlmock.Sqlmock
	// contains filtered or unexported fields
}

func NewCtx

func NewCtx(c *fiber.Ctx) (*Ctx, error)

func NewMockCtx

func NewMockCtx() *Ctx

func (*Ctx) DB

func (c *Ctx) DB(connName ...string) (*gorm.DB, error)

func (*Ctx) NewMockDB

func (c *Ctx) NewMockDB() (*gorm.DB, error)

func (*Ctx) TxBegin

func (c *Ctx) TxBegin() error

func (*Ctx) TxCommit

func (c *Ctx) TxCommit()

func (*Ctx) TxRollback

func (c *Ctx) TxRollback()

type LogInfo

type LogInfo struct {
	Error   string            `json:"error,omitempty"`
	Version string            `json:"version,omitempty"`
	Env     string            `json:"env,omitempty"`
	Method  string            `json:"method,omitempty"`
	Path    string            `json:"path,omitempty"`
	IP      []string          `json:"ip,omitempty"`
	Slug    string            `json:"slug,omitempty"`
	Email   string            `json:"email,omitempty"`
	Referer string            `json:"referer,omitempty"`
	Trace   map[string]string `json:"trace,omitempty"`
}

func NewLogInfo

func NewLogInfo() LogInfo

type User

type User struct {
	ID    string
	Name  string
	Phone string
	Email string
	Acl   map[string]bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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