common

package
v0.0.0-...-e07d5b6 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Client *mongo.Client

Functions

func AddRoute

func AddRoute(app *gin.Engine, route Route)

func AddRoutes

func AddRoutes(app *gin.Engine, routes []Route)

func BadRequestError

func BadRequestError(c *gin.Context, err error)

func CloseMongoConnection

func CloseMongoConnection()

func Created

func Created(c *gin.Context, data any)

func GetAppKey

func GetAppKey() string

func GetCollection

func GetCollection(collection string) *mongo.Collection

func GetJWTPrivateKey

func GetJWTPrivateKey() *rsa.PrivateKey

func GetJWTPublicKey

func GetJWTPublicKey() *rsa.PublicKey

func GetMongoConnection

func GetMongoConnection() (*mongo.Client, error)

func HandleError

func HandleError(c *gin.Context, statusCode int, err error)

func HandleUncaughtError

func HandleUncaughtError() gin.RecoveryFunc

func InitApp

func InitApp() (*gin.Engine, error)

func InitDB

func InitDB() (*mongo.Database, error)

func InternalServerError

func InternalServerError(c *gin.Context, err error)

func NotFoundError

func NotFoundError(c *gin.Context, err error)

func OK

func OK(c *gin.Context, data any)

func OpenMongoConnection

func OpenMongoConnection()

func Respond

func Respond(c *gin.Context, statusCode int, data any)

func UnauthorizedError

func UnauthorizedError(c *gin.Context, err error)

Types

type Audit

type Audit struct {
	CreatedBy string  `json:"createdBy" bson:"created_by"`
	UpdatedBy *string `json:"updatedBy" bson:"updated_by"`
	DeletedBy *string `json:"deletedBy" bson:"deleted_by"`
}

type Image

type Image struct {
	URL    string  `json:"url" bson:"url"`
	Width  float32 `json:"width" bson:"width"`
	Height float32 `json:"height" bson:"height"`
}

type RoomEntity

type RoomEntity struct {
	Key  string `json:"key" bson:"key"`
	Name string `json:"name" bson:"name"`
}

type Route

type Route struct {
	Name     string
	Method   string
	URI      string
	Handlers gin.HandlersChain
}

type Timestamps

type Timestamps struct {
	CreatedAt time.Time  `json:"createdAt" bson:"created_at"`
	UpdatedAt *time.Time `json:"updatedAt" bson:"updated_at"`
	DeletedAt *time.Time `json:"deletedAt" bson:"deleted_at"`
}

type UUID

type UUID struct {
	ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
}

type UserEntity

type UserEntity struct {
	ID       primitive.ObjectID `json:"id" bson:"id"`
	Username string             `json:"username" bson:"username"`
}

Jump to

Keyboard shortcuts

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