domain

package
v0.0.0-...-91867a4 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound = errors.New("No user found.")
	ErrExpiredToken = errors.New("jwt token expired")
	ErrInvalidToken = errors.New("invalid token")
)

Functions

This section is empty.

Types

type JWT

type JWT interface {
	CreateToken(user User, duration time.Duration) (*JWTPayload, error)
	VerifyToken(tokn string) (*JWTPayload, error)
}

type JWTPayload

type JWTPayload struct {
	UserID    int64     `json:"user_id"`
	ExpiresAt time.Time `json:"expires_at"`
	IssuedAt  time.Time `json:"issued_at"`
	Token     string    `json:"token"`
}

func (*JWTPayload) Valid

func (p *JWTPayload) Valid() error

type Post

type Post struct {
	ID        int64     `json:"id"`
	UserID    int64     `json:"user_id"`
	Title     string    `json:"title"`
	Body      string    `json:"body"`
	CreatedAt time.Time `json:"created_at"`
}

type Store

type Store interface {
	CreateUser(usr *User) (*User, error)
	DeleteUserByID(id int64) error
	DeleteAllUsers() error
	FindUserByEmail(email string) (*User, error)
	FindUserByID(id int64) (*User, error)
}

type User

type User struct {
	ID       int64  `json:"id"`
	Email    string `json:"email"`
	Password string `json:"password"`
	Name     string `json:"name"`
}

Jump to

Keyboard shortcuts

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