domain

package
v0.0.0-...-725965c Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Admin

type Admin struct {
	ID        int       `json:"id"`
	Name      string    `json:"name"`
	Email     string    `json:"email"`
	Password  string    `json:"password"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

A Admin represents the singular of admin.

func (*Admin) VerifyPassword

func (a *Admin) VerifyPassword(hashedPassword []byte, reqPassword []byte) error

VerifyPassword verfies hashed password and requested password.

type Admins

type Admins []Admin

A Admins represents the plural of admin.

type Categories

type Categories []Category

A Categories represents the plural of category.

type Category

type Category struct {
	ID        int       `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

A Category represents the singular of category.

type Comment

type Comment struct {
	ID        int       `json:"id"`
	PostID    int       `json:"post"`
	Body      string    `json:"body"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

A Comment represents the singular of comment.

type Comments

type Comments []Comment

A Comments represents the plural of comment.

type Config

type Config struct {
	ID        int       `json:"id"`
	Key       string    `json:"key"`
	Name      string    `json:"name"`
	Value     string    `json:"value"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

A Config represents the singular of config.

type Configs

type Configs []Config

A Configs represents the plural of config.

type JWT

type JWT struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	AccessUUID   string `json:"access_uuid"`
	RefreshUUID  string `json:"refresh_uuid"`
	AtExpires    int64  `json:"at_expires"`
	RtExpires    int64  `json:"rt_expires"`
}

A JWT represents the singular of jwt authentication.

func (*JWT) CreateAccessToken

func (j *JWT) CreateAccessToken(id int) (string, error)

CreateAccessToken creates an access token.

func (*JWT) CreateRefreshToken

func (j *JWT) CreateRefreshToken(id int) (string, error)

CreateRefreshToken creates a refresh token.

func (*JWT) ExtractAccessUUID

func (j *JWT) ExtractAccessUUID(t *jwt.Token) (string, error)

ExtractAccessUUID extract data from a verified token.

func (*JWT) ExtractRefreshUUID

func (j *JWT) ExtractRefreshUUID(t *jwt.Token) (string, error)

ExtractRefreshUUID extract data from a verified token.

func (*JWT) ExtractToken

func (j *JWT) ExtractToken(bearToken string) string

ExtractToken extract a token from authorization header in request. For example, if bearToken is "Bearer abcd.efgh.ijkl", return "abcd..efgh.ijkl"

func (*JWT) GetAccessUUID

func (j *JWT) GetAccessUUID(verifiedToken *jwt.Token) (string, error)

GetAccessUUID gets an access uuid from request Authorization header.

func (*JWT) GetRefreshUUID

func (j *JWT) GetRefreshUUID(verifiedToken *jwt.Token) (string, error)

GetRefreshUUID gets an refresh uuid from request Authorization header.

func (*JWT) GetVerifiedAccessToken

func (j *JWT) GetVerifiedAccessToken(bearerToken string) (*jwt.Token, error)

GetVerifiedAccessToken gets a verified token from a bearer token.

func (*JWT) GetVerifiedRefreshToken

func (j *JWT) GetVerifiedRefreshToken(bearerToken string) (*jwt.Token, error)

GetVerifiedRefreshToken gets a verified token from a bearer token.

func (*JWT) VerifyToken

func (j *JWT) VerifyToken(token string, secret string) (*jwt.Token, error)

VerifyToken verifies jwt. See: https://godoc.org/github.com/dgrijalva/jwt-go#example-Parse--Hmac

type Logger

type Logger interface {
	WithTraceID(context.Context) context.Context
	Error(string, ...any)
	ErrorContext(context.Context, string, ...any)
	Info(string, ...any)
	InfoContext(context.Context, string, ...any)
}

A Logger is a logger interface.

type Post

type Post struct {
	ID        int       `json:"id"`
	Admin     Admin     `json:"admin"`
	Category  Category  `json:"category"`
	Tags      Tags      `json:"tags"`
	Title     string    `json:"title"`
	MDBody    string    `json:"md_body"`
	HTMLBody  string    `json:"html_body"`
	Status    string    `json:"status"`
	Comments  Comments  `json:"comments"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

A Post represents the singular of post.

type Posts

type Posts []Post

A Posts represents the plural of post.

type Tag

type Tag struct {
	ID        int       `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

A Tag represetns the singular of tag.

type Tags

type Tags []Tag

A Tags represents the plural of tag.

Jump to

Keyboard shortcuts

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