server

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitHubAuth

func GitHubAuth(secret string) func(http.Handler) http.Handler

GitHubAuth is a HTTP middleware that verifies the HMAC SHA-265 signature sent by GitHub.

func GithubWebHookHandler

func GithubWebHookHandler(notifier Notifier, store Store, l *slog.Logger) http.Handler

A GithubWebHookHandler receives events from a Slack App. The current implementation is limited to StarEvents.

func Run

func Run(ctx context.Context, version string, l *slog.Logger) error

func Scan

func Scan(
	ctx context.Context,
	user string,
	c Client,
	s Store,
	n Notifier,
	includeArchived bool,
	l *slog.Logger,
) error

Scan retrieves all repositories for the user, gets the stars for each repository and adds new ones to the Store.

Types

type Client

type Client interface {
	GetUserRepos(ctx context.Context, user string) iter.Seq2[*github.Repository, error]
	GetStarGazers(ctx context.Context, repository *github.Repository) ([]*github.Stargazer, error)
}

type Notifier

type Notifier interface {
	Notify(repository *github.Repository, gazers []*github.Stargazer, added bool)
}

type Notifiers

type Notifiers []Notifier

func (Notifiers) Notify

func (n Notifiers) Notify(repository *github.Repository, gazers []*github.Stargazer, added bool)

type SLogNotifier

type SLogNotifier struct {
	Logger *slog.Logger
}

func (SLogNotifier) Notify

func (s SLogNotifier) Notify(repository *github.Repository, gazers []*github.Stargazer, added bool)

type SlackNotifier

type SlackNotifier struct {
	WebHookURL string
	Logger     *slog.Logger
}

func (SlackNotifier) Notify

func (s SlackNotifier) Notify(repository *github.Repository, gazers []*github.Stargazer, added bool)

type Store

type Store interface {
	SetStargazers(repository *github.Repository, stargazers []*github.Stargazer) ([]*github.Stargazer, error)
	Add(repo *github.Repository, stargazer *github.Stargazer) (bool, error)
	Delete(repo *github.Repository, stargazer *github.Stargazer) (bool, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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