services

package
v0.0.0-...-23e23d4 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func CacheOneNote

func CacheOneNote(userId primitive.ObjectID, note *models.Note)

func CheckRedisConnection

func CheckRedisConnection()

func CheckUserMail

func CheckUserMail(email string) error

CheckUserMail search user by email, return error if someone uses

func CreateNote

func CreateNote(userId primitive.ObjectID, title string, content string) (*db.Note, error)

CreateNote create new note record

func CreateToken

func CreateToken(user *db.User, tokenType string, expiresAt time.Time) (*db.Token, error)

CreateToken create a new token record

func CreateUser

func CreateUser(name string, email string, plainPassword string) (*db.User, error)

CreateUser create a user record

func DeleteNote

func DeleteNote(userId primitive.ObjectID, noteId primitive.ObjectID) error

DeleteNote delete a note with id

func DeleteTokenById

func DeleteTokenById(tokenId primitive.ObjectID) error

DeleteTokenById delete token with id

func FindUserByEmail

func FindUserByEmail(email string) (*db.User, error)

FindUserByEmail find user by email

func FindUserById

func FindUserById(userId primitive.ObjectID) (*db.User, error)

FindUserById find user by id

func GenerateAccessTokens

func GenerateAccessTokens(user *db.User) (*db.Token, *db.Token, error)

GenerateAccessTokens generates "access" and "refresh" token for user

func GetNoteById

func GetNoteById(userId primitive.ObjectID, noteId primitive.ObjectID) (*db.Note, error)

func GetNoteFromCache

func GetNoteFromCache(userId primitive.ObjectID, noteId primitive.ObjectID) (*models.Note, error)

func GetNotes

func GetNotes(userId primitive.ObjectID, page int, limit int) ([]db.Note, error)

GetNotes get paginated note list

func GetRedisCache

func GetRedisCache() *cache.Cache

func GetRedisDefaultClient

func GetRedisDefaultClient() *redis.Client

func InitMongoDB

func InitMongoDB()

func LoadConfig

func LoadConfig()

func UpdateNote

func UpdateNote(userId primitive.ObjectID, noteId primitive.ObjectID, request *models.NoteRequest) error

UpdateNote updates a note with id

func VerifyToken

func VerifyToken(token string, tokenType string) (*db.Token, error)

VerifyToken checks jwt validity, expire date, blacklisted

Types

This section is empty.

Jump to

Keyboard shortcuts

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