bookmarks

package
v0.0.0-...-ff9d945 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package bookmarks provides ways to interact with the bookmarks, such as adding a new bookmark

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAuthorized = errors.New("user does not have permission to create bookmark on collection")

ErrNotAuthorized an error when user is not authorized to perform an action

Functions

func AddHandlers

func AddHandlers(app core.App)

AddHandlers sets up the http handlers

Types

type Bookmark

type Bookmark struct {
	models.BaseModel

	Collection       string `db:"collection" json:"collection"`
	Favourite        bool   `db:"favourite" json:"favourite"`
	CustomOrder      int    `db:"custom_order" json:"custom_order"`
	BookmarkMetadata string `db:"bookmark_metadata" json:"bookmark_metadata"`
	User             string `db:"user" json:"user"`
}

Bookmark models the data in the `bookmarks` collection.

func (*Bookmark) TableName

func (m *Bookmark) TableName() string

TableName returns the name of the model in PocketBase.

type BookmarkMetaData

type BookmarkMetaData struct {
	models.BaseModel

	URL         string `db:"url" json:"url"`
	Description string `db:"description" json:"description"`
	Title       string `db:"title" json:"title"`
	Image       string `db:"image" json:"image"`
}

BookmarkMetaData is model the represents data related to URL

func (*BookmarkMetaData) TableName

func (m *BookmarkMetaData) TableName() string

TableName returns the name of the model in PocketBase.

type CollectionService

type CollectionService interface {
	IsCollectionOwnedBy(collectionID string, userID string) (bool, error)
}

CollectionService is used to interact with the collection service

type GetURLMetadata

type GetURLMetadata struct {
	URL string `json:"url" validate:"required,url"`
}

GetURLMetadata struct contains all the fields used to create a new Bookmark

type Handler

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

Handler are all the HTTP handlers

func NewTransport

func NewTransport(service Servicer) Handler

NewTransport returns a new Transport struct to call methods in this module

func (Handler) CreateBookmark

func (h Handler) CreateBookmark(c echo.Context) error

CreateBookmark used to create a new bookmark in the app

func (Handler) GetURLMetadata

func (h Handler) GetURLMetadata(c echo.Context) error

GetURLMetadata gets the metadata associated with a URL

type NewBookmark

type NewBookmark struct {
	URL string `json:"url" validate:"required,url"`
}

NewBookmark struct contains all the fields used to create a new Bookmark

type Repository

type Repository interface {
	Create(metadata *BookmarkMetaData, collectionID string, userID string) error
	GetByURL(url string) (*BookmarkMetaData, error)
}

Repository is an interface for interacting with the database

type SQLiteStore

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

SQLiteStore used to interact with DB

func NewStore

func NewStore(app core.App) SQLiteStore

NewStore returns a new store to interact with the database

func (SQLiteStore) Create

func (s SQLiteStore) Create(metadata *BookmarkMetaData, collectionID string, userID string) error

Create creates a new Bookmark and BookmarkMeta entry in the database

func (SQLiteStore) GetByURL

func (s SQLiteStore) GetByURL(url string) (*BookmarkMetaData, error)

GetByURL get metadata info from the databas

type Service

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

Service used to interact with the bookmark

func NewService

func NewService(repo Repository, srv CollectionService) Service

NewService returns a new struct used to interact with this module

func (Service) Create

func (s Service) Create(url, collectionID, userID string) error

Create used to create a new bookmark

func (Service) GetMetadata

func (s Service) GetMetadata(url string) (*BookmarkMetaData, error)

GetMetadata returns the metadata for a URL.

type Servicer

type Servicer interface {
	Create(url, collectionID, userID string) error
	GetMetadata(url string) (*BookmarkMetaData, error)
}

Servicer used to interact with the service module

Jump to

Keyboard shortcuts

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