configs

package
v0.0.0-...-1235e82 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPassword hash compares raw password with it's hashed values

func EnvMongoURI

func EnvMongoURI() string

Helps retrieve the MongoDB URI fron the env file

func GenerateToken

func GenerateToken(username string, secretKey string) (string, error)

GenerateToken generates a jwt token and assign a username to it's claims and return it

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes given password

func ParseToken

func ParseToken(tokenStr string, secretKey string) (string, error)

ParseToken parses a jwt token and returns the username in it's claims

Types

type DB

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

func ConnectDB

func ConnectDB() *DB

func (*DB) CreateChatboard

func (db *DB) CreateChatboard(input *model.NewChatboard) (*model.Chatboard, error)

func (*DB) CreateComment

func (db *DB) CreateComment(input *model.NewComment) (*model.Comment, error)

func (*DB) CreateMessage

func (db *DB) CreateMessage(input *model.NewMessage) (*model.Message, error)

func (*DB) CreatePost

func (db *DB) CreatePost(input *model.NewPost) (*model.Post, error)

func (*DB) CreateUser

func (db *DB) CreateUser(input *model.NewUser) (*model.User, error)

func (*DB) GetChatboards

func (db *DB) GetChatboards() ([]*model.Chatboard, error)

func (*DB) GetComments

func (db *DB) GetComments() ([]*model.Comment, error)

func (*DB) GetMessages

func (db *DB) GetMessages() ([]*model.Message, error)

func (*DB) GetPosts

func (db *DB) GetPosts() ([]*model.Post, error)

func (*DB) GetUserIdByUsername

func (db *DB) GetUserIdByUsername(username string) (string, error)

func (*DB) GetUsers

func (db *DB) GetUsers() ([]*model.User, error)

func (*DB) SingleChatboard

func (db *DB) SingleChatboard(ID string) (*model.Chatboard, error)

func (*DB) SingleComment

func (db *DB) SingleComment(ID string) (*model.Comment, error)

func (*DB) SingleMessage

func (db *DB) SingleMessage(ID string) (*model.Message, error)

func (*DB) SinglePost

func (db *DB) SinglePost(ID string) (*model.Post, error)

func (*DB) SingleUser

func (db *DB) SingleUser(ID string) (*model.User, error)

type User

type User struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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