server

package
v0.0.0-...-4eccbda Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JWTSecret = "EBA6AA5E6CA19689C479902C8E0B68B784CD22DFFEC7356AF7B17FEF3F17C778"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	DB         *bun.DB
	Api        fiber.Router
	FP         *fbun.FiPer
	Ctx        context.Context
	TokenCache *redis.Client
	Err        error
}

func (*Data) DeleteBook

func (d *Data) DeleteBook(c *fiber.Ctx) (err error)

func (*Data) GetBook

func (d *Data) GetBook(c *fiber.Ctx) (err error)

func (*Data) GetBooks

func (d *Data) GetBooks(c *fiber.Ctx) (err error)

func (*Data) InitDB

func (d *Data) InitDB()

func (*Data) InitTokenCache

func (d *Data) InitTokenCache()

InitTokenCache - Init data store instance to save users tokens info

func (Data) IsRequired

func (d Data) IsRequired() fiber.Handler

func (*Data) Login

func (d *Data) Login(c *fiber.Ctx) (err error)

func (Data) LoginQuery

func (d Data) LoginQuery(email, password string) (user User, err error)

func (*Data) Logout

func (d *Data) Logout(c *fiber.Ctx) (err error)

func (*Data) MigrateDB

func (d *Data) MigrateDB()

func (*Data) NewBook

func (d *Data) NewBook(c *fiber.Ctx) (err error)

func (*Data) SetupAuthRoutes

func (d *Data) SetupAuthRoutes(router fiber.Router)

func (*Data) SetupBookRoutes

func (d *Data) SetupBookRoutes(router fiber.Router)

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type SessionInfo

type SessionInfo struct {
	Browser string
	IP      string
	System  string
}

SessionInfo - Sessin info Data

type TokenCache

type TokenCache struct {
	UserID      uuid.UUID `json:"userID"`
	UserPermits []string  `json:"userPermits"`
	CreatedAt   time.Time `json:"createdAt"`
	ExpireAt    time.Time `json:"expireAt"`
}

TokenCache - Token Cache fields

type User

type User struct {
	ID       uuid.UUID `json:"id" bun:",pk,type:uuid,default:uuid_generate_v4()"`
	Email    string    `json:"email" bun:",unique,notnull"`
	Password string    `json:"password"`
	Permits  []string  `json:"permits" bun:",array"`
}

Jump to

Keyboard shortcuts

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