api

package
v0.0.0-...-96234d7 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

Min returns the smaller of x or y.

func New

func New(port *string, apiConfig string)

Types

type API

type API struct {
	weoscontroller.API
	Application weos.Application
	Log         weos.Log
	DB          *sql.DB
	Client      *http.Client
	// contains filtered or unexported fields
}

func (*API) AddBlog

func (a *API) AddBlog(e echo.Context) error

func (*API) GetAuthors

func (a *API) GetAuthors(e echo.Context) error

Get list of authors

func (*API) GetCategories

func (a *API) GetCategories(e echo.Context) error

Get list of categories

func (*API) GetPosts

func (a *API) GetPosts(e echo.Context) error

Get list of posts.

func (*API) HealthCheck

func (a *API) HealthCheck(e echo.Context) error

health check handler

func (*API) Initialize

func (a *API) Initialize() error

type Author

type Author struct {
	gorm.Model
	Name   string `json:"name"`
	Email  string `json:"email"`
	BlogID string `json:"blogId"`
}

type Blog

type Blog struct {
	gorm.Model
	ID          string    `gorm:"primarykey"`
	Title       string    `json:"title,omitempty"`
	Description string    `json:"description,omitempty"`
	URL         string    `json:"url,omitempty"`
	FeedURL     string    `json:"feedUrl,omitempty"`
	Authors     []*Author `json:"authors,omitempty"`
	Posts       []*Post   `json:"posts,omitempty"`
}

type Category

type Category struct {
	gorm.Model
	Title       string  `json:"title"`
	Description string  `json:"description"`
	Posts       []*Post `json:"posts,omitempty" gorm:"many2many:post_categories;"`
}

type CategoryList

type CategoryList struct {
	Limit int         `json:"limit"`
	Total int64       `json:"total"`
	Page  int         `json:"page"`
	Items []*Category `json:"items"`
}

type GORMProjection

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

func NewProjection

func NewProjection(application weos.Application) (*GORMProjection, error)

func (*GORMProjection) GetAuthors

func (p *GORMProjection) GetAuthors(page int, limit int, query string, sortOptions map[string]string, filterOptions map[string]interface{}) ([]*Author, int64, error)

GetAuthors get all the authors in the aggregator

func (*GORMProjection) GetBlogByID

func (p *GORMProjection) GetBlogByID(id string) (*Blog, error)

func (*GORMProjection) GetBlogByURL

func (p *GORMProjection) GetBlogByURL(url string) (*Blog, error)

func (*GORMProjection) GetBlogs

func (p *GORMProjection) GetBlogs() ([]*Blog, error)

func (*GORMProjection) GetCategories

func (p *GORMProjection) GetCategories(page int, limit int, sortOptions map[string]string, filterOptions map[string]interface{}) ([]*Category, int64, error)

func (*GORMProjection) GetEventHandler

func (p *GORMProjection) GetEventHandler() weos.EventHandler

func (*GORMProjection) GetPosts

func (p *GORMProjection) GetPosts(page int, limit int, query string, sortOptions map[string]string, filterOptions map[string]interface{}) ([]*Post, int64, error)

GetPosts get all the posts in the aggregator

func (*GORMProjection) Migrate

func (p *GORMProjection) Migrate(ctx context.Context) error

runs migrations

func (*GORMProjection) Persist

func (p *GORMProjection) Persist(entities []weos.Entity) error

func (*GORMProjection) Remove

func (p *GORMProjection) Remove(entities []weos.Entity) error

type Post

type Post struct {
	gorm.Model
	ID          string      `gorm:"primarykey"`
	Title       string      `json:"title"`
	Description string      `json:"description"`
	Content     string      `json:"content"`
	BlogID      string      `json:"blogId"`
	Blog        *Blog       `json:"blog"`
	Link        string      `json:"link"`
	Categories  []*Category `json:"categories,omitempty" gorm:"many2many:post_categories;"`
	Published   string      `json:"published"`
	PublishDate time.Time
	Views       int `json:"views"`
}

type PostList

type PostList struct {
	Limit int     `json:"limit"`
	Total int64   `json:"total"`
	Page  int     `json:"page"`
	Items []*Post `json:"items"`
}

type Projection

type Projection interface {
	weos.Projection
	GetBlogByID(id string) (*Blog, error)
	GetBlogByURL(url string) (*Blog, error)
	GetPosts(page int, limit int, query string, sortOptions map[string]string, filterOptions map[string]interface{}) ([]*Post, int64, error)
	GetCategories(page int, limit int, sortOptions map[string]string, filterOptions map[string]interface{}) ([]*Category, int64, error)
}

Jump to

Keyboard shortcuts

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