api

package
v0.0.0-...-06a3cf6 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.0 DO NOT EDIT.

Index

Constants

View Source
const (
	BearerAuthScopes = "bearerAuth.Scopes"
)

Variables

This section is empty.

Functions

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, m ServeMux) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

Types

type ActivitiesListResponse

type ActivitiesListResponse struct {
	// HasMore Whether there are more results available
	HasMore *bool `json:"hasMore,omitempty"`

	// NextCursor Cursor to use for fetching the next page of results
	NextCursor *string         `json:"nextCursor,omitempty"`
	Results    []Activity      `json:"results"`
	Topics     []ActivityTopic `json:"topics"`
}

ActivitiesListResponse defines model for ActivitiesListResponse.

type Activity

type Activity struct {
	// AmplificationCount Number of shares/reposts/forks/etc. -1 if not available.
	AmplificationCount int    `json:"amplificationCount"`
	Body               string `json:"body"`

	// CommentsCount Number of comments/discussions. -1 if not available.
	CommentsCount int       `json:"commentsCount"`
	CreatedAt     time.Time `json:"createdAt"`

	// FullSummary One-paragraph markdown summary.
	FullSummary string `json:"fullSummary"`
	ImageUrl    string `json:"imageUrl"`

	// ShortSummary One-line short plain text summary.
	ShortSummary string     `json:"shortSummary"`
	Similarity   *float32   `json:"similarity,omitempty"`
	SourceType   SourceType `json:"sourceType"`
	SourceUids   []string   `json:"sourceUids"`
	Title        string     `json:"title"`
	Uid          string     `json:"uid"`

	// UpvotesCount Number of upvotes/likes. -1 if not available.
	UpvotesCount int    `json:"upvotesCount"`
	Url          string `json:"url"`
}

Activity defines model for Activity.

type ActivityPeriod

type ActivityPeriod string

ActivityPeriod Time period to filter activities from. 'month' means last month, 'week' means last week, 'day' means last day.

const (
	All   ActivityPeriod = "all"
	Day   ActivityPeriod = "day"
	Month ActivityPeriod = "month"
	Week  ActivityPeriod = "week"
)

Defines values for ActivityPeriod.

type ActivitySortBy

type ActivitySortBy string

ActivitySortBy defines model for ActivitySortBy.

const (
	CreationDate ActivitySortBy = "creationDate"
	Similarity   ActivitySortBy = "similarity"
)

Defines values for ActivitySortBy.

type ActivityTopic

type ActivityTopic struct {
	// ActivityIds List of activity IDs in this topic.
	ActivityIds []string `json:"activityIds"`

	// Emoji Emoji character for the topic.
	Emoji string `json:"emoji"`

	// Queries LLM generated sub-queries used to filter activities for this topic.
	Queries []string `json:"queries"`

	// Summary Summary of the activities in this topic.
	Summary string `json:"summary"`

	// Title Title of the topic.
	Title string `json:"title"`
}

ActivityTopic defines model for ActivityTopic.

type Config

type Config struct {
	Host       string `env:"SERVER_HOST,default=localhost"`
	Port       uint16 `env:"SERVER_PORT,default=8080"`
	Proxied    bool   `env:"SERVER_PROXIED,default=false"`
	AssetsPath string `env:"SERVER_ASSETS_PATH,default=./assets"`
	BaseURL    string `env:"SERVER_BASE_URL,default=/"`
	FaviconURL string `env:"SERVER_FAVICON_URL,default="`
	// CORSOrigin is a comma-separated list of origins.
	CORSOrigin string      `env:"CORS_ORIGIN,default=*"`
	Auth       auth.Config `env:""`
}

type CreateFeedRequest

type CreateFeedRequest struct {
	Icon       string   `json:"icon"`
	Name       string   `json:"name"`
	Query      string   `json:"query"`
	SourceUids []string `json:"sourceUids"`
}

CreateFeedRequest defines model for CreateFeedRequest.

type CreateOwnFeedJSONRequestBody

type CreateOwnFeedJSONRequestBody = CreateFeedRequest

CreateOwnFeedJSONRequestBody defines body for CreateOwnFeed for application/json ContentType.

type Feed

type Feed struct {
	CreatedAt time.Time `json:"createdAt"`

	// CreatedBy ID of the user who created and owns the feed. Feed can only be modified by him.
	CreatedBy  string   `json:"createdBy"`
	Icon       string   `json:"icon"`
	IsPublic   bool     `json:"isPublic"`
	Name       string   `json:"name"`
	Query      string   `json:"query"`
	SourceUids []string `json:"sourceUids"`
	Uid        string   `json:"uid"`
}

Feed defines model for Feed.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type ListFeedActivitiesParams

type ListFeedActivitiesParams struct {
	// Period Time period to filter activities from. Defaults to 'all' for all time.
	Period *ActivityPeriod `form:"period,omitempty" json:"period,omitempty"`

	// SortBy Sort method.
	SortBy *ActivitySortBy `form:"sortBy,omitempty" json:"sortBy,omitempty"`

	// Query Filter query. Authenticated users can override the default feed query.
	Query *string `form:"query,omitempty" json:"query,omitempty"`

	// Limit Maximum number of activities to return.
	Limit *int `form:"limit,omitempty" json:"limit,omitempty"`

	// RewriteQuery Whether to rewrite the query to sub-queries and return results by topics.
	RewriteQuery *bool `form:"rewriteQuery,omitempty" json:"rewriteQuery,omitempty"`
}

ListFeedActivitiesParams defines parameters for ListFeedActivities.

type ListSourcesParams

type ListSourcesParams struct {
	// Query Filter sources by name or description.
	Query *string `form:"query,omitempty" json:"query,omitempty"`

	// Topics Optional list of user interests to personalize results. Example: interests=llms&interests=startups
	Topics *[]TopicTag `form:"topics,omitempty" json:"topics,omitempty"`
}

ListSourcesParams defines parameters for ListSources.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type ServeMux

type ServeMux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

ServeMux is an abstraction of http.ServeMux.

type Server

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

func NewServer

func NewServer(
	logger *zerolog.Logger,
	config *Config,
	authMiddleware *auth.RouteAuthMiddleware,
	sourceRegistry sourceRegistry,
	sourceScheduler *sources.Scheduler,
	feedRegistry *feeds.Registry,
) (*Server, error)

func (*Server) CreateOwnFeed

func (s *Server) CreateOwnFeed(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteOwnFeed

func (s *Server) DeleteOwnFeed(w http.ResponseWriter, r *http.Request, uid string)

func (*Server) GetMe

func (s *Server) GetMe(w http.ResponseWriter, r *http.Request)

func (*Server) GetSource

func (s *Server) GetSource(w http.ResponseWriter, r *http.Request, uid string)

func (*Server) ListFeedActivities

func (s *Server) ListFeedActivities(w http.ResponseWriter, r *http.Request, uid string, params ListFeedActivitiesParams)

func (*Server) ListFeeds

func (s *Server) ListFeeds(w http.ResponseWriter, r *http.Request)

func (*Server) ListSources

func (s *Server) ListSources(w http.ResponseWriter, r *http.Request, params ListSourcesParams)

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

func (*Server) UpdateOwnFeed

func (s *Server) UpdateOwnFeed(w http.ResponseWriter, r *http.Request, uid string)

type ServerInterface

type ServerInterface interface {
	// List public feeds and/or those belonging to the authenticated user
	// (GET /feeds)
	ListFeeds(w http.ResponseWriter, r *http.Request)
	// Create a feed belonging to the authenticated user
	// (POST /feeds)
	CreateOwnFeed(w http.ResponseWriter, r *http.Request)
	// Delete a feed belonging to the authenticated user
	// (DELETE /feeds/{uid})
	DeleteOwnFeed(w http.ResponseWriter, r *http.Request, uid string)
	// Update a feed belonging to the authenticated user
	// (PUT /feeds/{uid})
	UpdateOwnFeed(w http.ResponseWriter, r *http.Request, uid string)
	// List activities for a feed
	// (GET /feeds/{uid}/activities)
	ListFeedActivities(w http.ResponseWriter, r *http.Request, uid string, params ListFeedActivitiesParams)
	// List available sources
	// (GET /sources)
	ListSources(w http.ResponseWriter, r *http.Request, params ListSourcesParams)
	// Get source by UID
	// (GET /sources/{uid})
	GetSource(w http.ResponseWriter, r *http.Request, uid string)
	// Get authenticated user information
	// (GET /users/me)
	GetMe(w http.ResponseWriter, r *http.Request)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CreateOwnFeed

func (siw *ServerInterfaceWrapper) CreateOwnFeed(w http.ResponseWriter, r *http.Request)

CreateOwnFeed operation middleware

func (*ServerInterfaceWrapper) DeleteOwnFeed

func (siw *ServerInterfaceWrapper) DeleteOwnFeed(w http.ResponseWriter, r *http.Request)

DeleteOwnFeed operation middleware

func (*ServerInterfaceWrapper) GetMe

GetMe operation middleware

func (*ServerInterfaceWrapper) GetSource

func (siw *ServerInterfaceWrapper) GetSource(w http.ResponseWriter, r *http.Request)

GetSource operation middleware

func (*ServerInterfaceWrapper) ListFeedActivities

func (siw *ServerInterfaceWrapper) ListFeedActivities(w http.ResponseWriter, r *http.Request)

ListFeedActivities operation middleware

func (*ServerInterfaceWrapper) ListFeeds

func (siw *ServerInterfaceWrapper) ListFeeds(w http.ResponseWriter, r *http.Request)

ListFeeds operation middleware

func (*ServerInterfaceWrapper) ListSources

func (siw *ServerInterfaceWrapper) ListSources(w http.ResponseWriter, r *http.Request)

ListSources operation middleware

func (*ServerInterfaceWrapper) UpdateOwnFeed

func (siw *ServerInterfaceWrapper) UpdateOwnFeed(w http.ResponseWriter, r *http.Request)

UpdateOwnFeed operation middleware

type Source

type Source struct {
	Description string     `json:"description"`
	IconUrl     string     `json:"iconUrl"`
	Name        string     `json:"name"`
	TopicTags   []TopicTag `json:"topicTags"`
	Type        SourceType `json:"type"`
	Uid         string     `json:"uid"`
	Url         string     `json:"url"`
}

Source defines model for Source.

type SourceType

type SourceType string

SourceType defines model for SourceType.

const (
	ChangedetectionWebsite SourceType = "changedetectionWebsite"
	GithubIssues           SourceType = "githubIssues"
	GithubReleases         SourceType = "githubReleases"
	GithubTopics           SourceType = "githubTopics"
	HackernewsPosts        SourceType = "hackernewsPosts"
	LobstersFeed           SourceType = "lobstersFeed"
	LobstersTag            SourceType = "lobstersTag"
	MastodonAccount        SourceType = "mastodonAccount"
	MastodonTag            SourceType = "mastodonTag"
	ProductHuntPosts       SourceType = "productHuntPosts"
	RedditSubreddit        SourceType = "redditSubreddit"
	RssFeed                SourceType = "rssFeed"
)

Defines values for SourceType.

type StdHTTPServerOptions

type StdHTTPServerOptions struct {
	BaseURL          string
	BaseRouter       ServeMux
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type TopicTag

type TopicTag string

TopicTag Specific niche technology/startup interests

const (
	ArtificialIntelligence TopicTag = "artificial_intelligence"
	Automotive             TopicTag = "automotive"
	CloudInfrastructure    TopicTag = "cloud_infrastructure"
	ComputerScience        TopicTag = "computer_science"
	Databases              TopicTag = "databases"
	Devtools               TopicTag = "devtools"
	DistributedSystems     TopicTag = "distributed_systems"
	Finance                TopicTag = "finance"
	GrowthEngineering      TopicTag = "growth_engineering"
	LargeLanguageModels    TopicTag = "large_language_models"
	OpenSource             TopicTag = "open_source"
	ProductManagement      TopicTag = "product_management"
	Robotics               TopicTag = "robotics"
	Science                TopicTag = "science"
	SecurityEngineering    TopicTag = "security_engineering"
	Startups               TopicTag = "startups"
	SystemsProgramming     TopicTag = "systems_programming"
	Web3                   TopicTag = "web3"
	WebPerformance         TopicTag = "web_performance"
)

Defines values for TopicTag.

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

type UpdateFeedRequest

type UpdateFeedRequest = CreateFeedRequest

UpdateFeedRequest defines model for UpdateFeedRequest.

type UpdateOwnFeedJSONRequestBody

type UpdateOwnFeedJSONRequestBody = UpdateFeedRequest

UpdateOwnFeedJSONRequestBody defines body for UpdateOwnFeed for application/json ContentType.

type User

type User struct {
	// Email User email address (may be empty for some auth providers)
	Email *string `json:"email,omitempty"`

	// Id User ID
	Id string `json:"id"`
}

User defines model for User.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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