api

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

type Repo interface {
	GetTokens(ctx context.Context, userID int) ([]Token, error)
	GetToken(ctx context.Context, t Token) (Token, error)
	AddToken(ctx context.Context, t Token) (Token, error)
	DeleteToken(ctx context.Context, t Token) error
	DeleteOldToken(ctx context.Context) error
	// contains filtered or unexported methods
}

Repo is used for navigating a package

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store stores the dependencies

func NewAPIRepo

func NewAPIRepo(db *sqlx.DB) *Store

NewAPIRepo stores the dependency

func (*Store) AddToken

func (s *Store) AddToken(ctx context.Context, t Token) (Token, error)

AddToken adds a token id, name, description, user id and expiration, the actual jwt token is not stored

func (*Store) DeleteOldToken

func (s *Store) DeleteOldToken(ctx context.Context) error

DeleteOldToken deletes all old tokens by the subroutine

func (*Store) DeleteToken

func (s *Store) DeleteToken(ctx context.Context, t Token) error

DeleteToken deletes a specific token

func (*Store) GetToken

func (s *Store) GetToken(ctx context.Context, t Token) (Token, error)

GetToken returns a specific token

func (*Store) GetTokens

func (s *Store) GetTokens(ctx context.Context, userID int) ([]Token, error)

GetTokens returns all the tokens that a user has

type Token

type Token struct {
	TokenID     string    `db:"token_id" json:"tokenID"`
	Name        string    `db:"name" json:"name,omitempty"`
	Description string    `db:"description" json:"description,omitempty"`
	Expiry      null.Time `db:"expiry" json:"expiry"`
	UserID      int       `db:"user_id" json:"userID"`
}

Token is the struct for a token to be stored

Jump to

Keyboard shortcuts

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