utils

package
v0.0.0-...-eedabaa Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticateAdmin

func AuthenticateAdmin(fn manipulateAnythingFromAdmin) func(params graphql.ResolveParams) (interface{}, error)

AuthenticateAdmin checks if the user trying to access that resource is truly an Admin

func AuthenticateUser

func AuthenticateUser(fn manipulateAnythingFromUser) func(params graphql.ResolveParams) (interface{}, error)

AuthenticateUser checks if the user trying to access that resource is truly a user (customer, lawyer)

func GenerateRandomString

func GenerateRandomString(n int) string

GenerateRandomString generates a random string

func GetContextInjected

func GetContextInjected(ctx context.Context) (string, error)

GetContextInjected helps get the context data with the specific key given to that context value

func GetPrincipalID

func GetPrincipalID() interface{}

GetPrincipalID returns a unique context value name for each hit

func GetResolvers

func GetResolvers(sample []map[string]*graphql.Field) map[string]*graphql.Field

GetReolvers helps you get reolvers from individual models

func MustGet

func MustGet(k string) string

MustGet will return the env or panic if it is not present

func MustGetBool

func MustGetBool(k string) bool

MustGetBool will return the env as boolean or panic if it is not present

func Sentry

func Sentry()

Sentry starts

func VerifyPayment

func VerifyPayment(reference string) (*paystack.Response, error)

Types

type AdminFromToken

type AdminFromToken struct {
	ID   string `json:"id"`
	Role string `json:"role"`
}

AdminFromToken unmarshals cliams from jwt to get admin id

type DateRangeType

type DateRangeType struct {
	StartTime time.Time `json:"start_time"`
	EndTime   time.Time `json:"end_time"`
}

DateRangeType typings

type FilterQuery

type FilterQuery struct {
	Limit     int            `json:"limit"`
	Skip      int            `json:"skip"`
	Order     string         `json:"order"`
	OrderBy   string         `json:"orderBy"`
	Search    *Search        `json:"search"`
	DateRange *DateRangeType `json:"dateRange"`
}

FilterQuery type to help generate filter for queries

func GenerateQuery

func GenerateQuery(argument map[string]interface{}) (*FilterQuery, error)

GenerateQuery takes a loook at what is coming from client and then generates a sieve

type Search struct {
	Criteria     string        `json:"criteria"`
	SearchFields []interface{} `json:"searchFields"`
}

Search typings

type UserFromToken

type UserFromToken struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

UserFromToken unmarshals cliams from jwt to get admin id

Jump to

Keyboard shortcuts

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