org

package
v0.0.0-...-1d3a159 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUserToken

func CreateUserToken(app *bunapp.App, userID uint64, ttl time.Duration) (string, error)

func HealthCheckHandler

func HealthCheckHandler(w http.ResponseWriter, req bunrouter.Request) error

Types

type FollowUser

type FollowUser struct {
	bun.BaseModel `bun:"alias:fu"`

	UserID         uint64
	FollowedUserID uint64
}

type HealthCheckResponse

type HealthCheckResponse struct {
	Status      string    `json:"status"`
	Message     string    `json:"message"`
	CurrentTime time.Time `json:"current_time"`
	Version     string    `json:"version"`
}

type Middleware

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

func NewMiddleware

func NewMiddleware(app *bunapp.App) Middleware

func (Middleware) MustUser

func (Middleware) User

type Profile

type Profile struct {
	bun.BaseModel `bun:"users,alias:u"`

	ID        uint64 `json:"-"`
	Username  string `json:"username"`
	Bio       string `json:"bio"`
	Image     string `json:"image"`
	Following bool   `bun:",scanonly" json:"following"`
}

func NewProfile

func NewProfile(user *User) *Profile

type Session

type Session struct {
	bun.BaseModel `bun:",alias:s"`

	ID             uint64                 `json:"-" bun:",pk,autoincrement"`
	UserId         uint64                 `json:"userId"`
	User           User                   `json:"user" bun:"rel:belongs-to"`
	Token          string                 `bun:",notnull,unique" json:"token,omitempty"`
	Provider       string                 `json:"provider" bun:"default:'LOCAL'"`
	LastTimeActive time.Time              `json:"lastTimeActive" bun:"default:current_timestamp"`
	ExpiresAt      time.Time              `json:"expiresAt"`
	DeviceInfo     map[string]interface{} `json:"deviceInfo" bun:"type:jsonb,default:'{}'"`
}

func SelectSessionByToken

func SelectSessionByToken(ctx context.Context, app *bunapp.App, token string) (*Session, error)

func SessionFromContext

func SessionFromContext(ctx context.Context) *Session

func (*Session) Destroy

func (s *Session) Destroy(ctx context.Context, app *bunapp.App) error

func (*Session) UpdateLastTimeActive

func (s *Session) UpdateLastTimeActive(ctx context.Context, app *bunapp.App) error

type SessionHandler

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

func NewSessionHandler

func NewSessionHandler(app *bunapp.App) SessionHandler

func (SessionHandler) Login

func (SessionHandler) Logout

type User

type User struct {
	bun.BaseModel `bun:",alias:u"`

	ID       uint64 `json:"-" bun:",pk,autoincrement"`
	Name     string `json:"name"`
	LastName string `json:"lastName"`
	Username string `json:"username" bun:",unique"`
	Email    string `json:"email"`
	Image    string `json:"image"`
	Password string `bun:",notnull" json:"password,omitempty"`
}

func SelectUser

func SelectUser(ctx context.Context, app *bunapp.App, id uint64) (*User, error)

func SelectUserByUsername

func SelectUserByUsername(ctx context.Context, app *bunapp.App, username string) (*User, error)

func UserFromContext

func UserFromContext(ctx context.Context) *User

func (*User) ComparePassword

func (u *User) ComparePassword(pass string) error

func (*User) CreateSession

func (u *User) CreateSession(app *bunapp.App, r *http.Request) (Session, error)

type UserHandler

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

func NewUserHandler

func NewUserHandler(app *bunapp.App) UserHandler

func (UserHandler) Create

func (*UserHandler) Current

func (UserHandler) Follow

func (UserHandler) Profile

func (UserHandler) Unfollow

func (UserHandler) Update

Jump to

Keyboard shortcuts

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