utils

package
v0.0.0-...-6d6c83b Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAccessToken

func GenerateAccessToken(data dto.UserData) (string, int64, error)

GenerateAccessToken membuat access token dengan durasi tertentu

func GenerateRefreshToken

func GenerateRefreshToken(userID string) (string, error)

GenerateRefreshToken membuat refresh token dengan durasi tertentu

func GetPaginationParams

func GetPaginationParams(pageStr, perPageStr string) (int, int)

func SetRefreshTokenCookie

func SetRefreshTokenCookie(c *fiber.Ctx, refreshString string)

func ValidateStruct

func ValidateStruct(data interface{}) error

Types

type ErrorDetails

type ErrorDetails struct {
	Code    string   `json:"code"`
	Message []string `json:"message"`
}

type ErrorResponse

type ErrorResponse struct {
	Status string       `json:"status"`
	Error  ErrorDetails `json:"error"`
}

type Meta

type Meta struct {
	CurrentPage      int `json:"currentPage"`
	PerPage          int `json:"perPage"`
	TotalCurrentPage int `json:"totalCurrentPage"`
	TotalPage        int `json:"totalPage"`
	TotalData        int `json:"totalData"`
}

func MetaPagination

func MetaPagination(
	page int,
	perPage int,
	totalCurrentPage int,
	total int,
) Meta

type QueryParams

type QueryParams struct {
	Page    string `query:"page"`
	PerPage string `query:"perPage"`
	Sort    string `query:"sort"`
	Search  string `query:"search"`
	Status  string `query:"status"`
}

type ResponseData

type ResponseData struct {
	Status  string      `json:"status"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
	Meta    *Meta       `json:"meta,omitempty"`
}

type ResponseHandler

type ResponseHandler struct{}

func (*ResponseHandler) BadRequest

func (h *ResponseHandler) BadRequest(c *fiber.Ctx, messages []string) error

func (*ResponseHandler) Created

func (h *ResponseHandler) Created(c *fiber.Ctx, data interface{}, message string) error

func (*ResponseHandler) Forbidden

func (h *ResponseHandler) Forbidden(c *fiber.Ctx, messages []string) error

func (*ResponseHandler) InternalServerError

func (h *ResponseHandler) InternalServerError(c *fiber.Ctx, messages []string) error

func (*ResponseHandler) NotFound

func (h *ResponseHandler) NotFound(c *fiber.Ctx, messages []string) error

func (*ResponseHandler) Ok

func (h *ResponseHandler) Ok(
	c *fiber.Ctx,
	data interface{},
	message string,
	meta *Meta,
) error

func (*ResponseHandler) Unauthorized

func (h *ResponseHandler) Unauthorized(c *fiber.Ctx, messages []string) error

Jump to

Keyboard shortcuts

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