npgc

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 10 Imported by: 0

README

npgcommon

Contains all commons API and function to be use in each and every micro-services codebase.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthVerify

func AuthVerify(app *fiber.App)

func CreateRestHook

func CreateRestHook(app *fiber.App)

func DefaultErrorResponse

func DefaultErrorResponse(ctx *fiber.Ctx, err error) error

func GetSubFromToken

func GetSubFromToken(tokenString string) (string, error)

func Load

func Load(fileName string)

func LoadEnv

func LoadEnv()

This function will load the env vars form the .env, so all repo uses this function must provide .env file in their directory

Types

type AppConfig

type AppConfig struct {
	Port        string
	ServiceName string
	DB          DBConfig
	Auth        AuthConfig
}
var Config *AppConfig

func New

func New() *AppConfig

type AuthConfig

type AuthConfig struct {
	JWTSecret      string
	PublicKeyPath  string
	PrivateKeyPath string
	Kid            string
	Issuer         string
}

type DBConfig

type DBConfig struct {
	URI      string
	AuthType string
	Username string
	Password string
}

type JWTBuilder

type JWTBuilder struct {
	Expiry   int64
	IssuedAt int64
	Issuer   string
	Subject  string
	Secret   []byte
}

func (JWTBuilder) CreateJWT

func (jt JWTBuilder) CreateJWT() (*string, error)

type JWTHeader

type JWTHeader struct {
	Typ string `json:"typ"`
	Kid string `json:"kid"`
	Alg string `json:"alg"`
}

Use for our napig custom jwt headers throughout all microservices.

type RestResponse

type RestResponse struct {
	Context    *fiber.Ctx
	HTTPStatus int
	Payload    interface{}
	Status     string
}

func (RestResponse) SendResponse

func (rr RestResponse) SendResponse() error

type UserSubContextKey

type UserSubContextKey string
var UserSubKey UserSubContextKey = "user_id"

Jump to

Keyboard shortcuts

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