web

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: AGPL-3.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.5.0

type Config struct {
	Mode     Mode   `mapstructure:"mode" yaml:"mode"`
	Url      string `mapstructure:"url" yaml:"url"`
	Port     string `mapstructure:"port" yaml:"port"`
	TimeZone string `mapstructure:"time_zone" yaml:"time_zone"`

	CookieSecret string `mapstructure:"cookie_secret" yaml:"cookie_secret"`

	GoogleAuth GoogleAuthConfig `mapstructure:"google_auth" yaml:"google_auth"`

	Sendgrid SendgridConfig `yaml:"sendgrid" mapstructure:"sendgrid"`

	SMTP SMTPConfig `yaml:"smtp" mapstructure:"smtp"`

	DatabaseConfig `yaml:"db" mapstructure:"db"`
}

func (Config) EmailService added in v0.5.0

func (s Config) EmailService() email.Service

func (Config) Valid added in v0.5.0

func (s Config) Valid() error

type DataAccess added in v0.5.0

type DataAccess struct {
	ProblemStore  problems.Store
	MailService   email.Service
	PartialsStore templates.Store

	Categories          njudge.Categories
	Tags                njudge.Tags
	Problems            njudge.Problems
	Users               njudge.Users
	Submissions         njudge.Submissions
	SolvedStatusQuery   njudge.SolvedStatusQuery
	ProblemInfoQuery    njudge.ProblemInfoQuery
	ProblemQuery        njudge.ProblemQuery
	ProblemListQuery    njudge.ProblemListQuery
	SubmissionListQuery njudge.SubmissionListQuery
	Problemsets         njudge.Problemsets

	SubmitService             *njudge.SubmitService
	TagsService               njudge.TagsService
	TaskArchiveService        njudge.TaskArchiveService
	ProblemsetRanklistService njudge.ProblemsetRanklistService
}

DataAccess provides access to the business logic in handlers

func NewDBDataAccess added in v0.5.0

func NewDBDataAccess(ctx context.Context, ps problems.Store, DB *sql.DB, ms email.Service) (*DataAccess, error)

NewDBDataAccess creates a DataAccess backed by "database"-kind business logic (internal/njudge/db)

func NewDemoDataAccess added in v0.5.0

func NewDemoDataAccess(ctx context.Context, ps problems.Store, ms email.Service) (*DataAccess, error)

NewDemoDataAccess creates in-memory (internal/njudge/memory) "demo" data

type DatabaseConfig added in v0.5.0

type DatabaseConfig struct {
	User     string `mapstructure:"user" yaml:"user"`
	Password string `mapstructure:"password" yaml:"password"`
	Host     string `mapstructure:"host" yaml:"host"`
	Name     string `mapstructure:"name" yaml:"name"`
	Port     int    `mapstructure:"port" yaml:"port"`
	SSLMode  bool   `mapstructure:"ssl_mode" yaml:"ssl_mode"`
}

func (DatabaseConfig) Connect added in v0.5.0

func (db DatabaseConfig) Connect() (*sql.DB, error)

func (DatabaseConfig) ConnectAndPing added in v0.5.0

func (db DatabaseConfig) ConnectAndPing(log *slog.Logger) (*sql.DB, error)

type GoogleAuthConfig added in v0.5.0

type GoogleAuthConfig struct {
	Enabled   bool   `mapstructure:"enabled" yaml:"enabled"`
	ClientKey string `mapstructure:"client_key" yaml:"client_key"`
	Secret    string `mapstructure:"secret" yaml:"secret"`
}

type Mode added in v0.5.0

type Mode string
const (
	ModeDebug       Mode = "debug"
	ModeDevelopment Mode = "development"
	ModeDemo        Mode = "demo"
	ModeProduction  Mode = "production"
)

func (Mode) UsesDB added in v0.5.0

func (m Mode) UsesDB() bool

func (Mode) Valid added in v0.5.0

func (m Mode) Valid() bool

type SMTPConfig added in v0.5.0

type SMTPConfig struct {
	Enabled             bool   `yaml:"enabled" mapstructure:"enabled"`
	MailAccount         string `yaml:"mail_account" mapstructure:"mail_account"`
	MailServerHost      string `yaml:"mail_server" mapstructure:"mail_server"`
	MailServerPort      int    `yaml:"mail_port" mapstructure:"mail_port"`
	MailAccountPassword string `yaml:"mail_password" mapstructure:"mail_password"`
}

type SendgridConfig added in v0.5.0

type SendgridConfig struct {
	Enabled       bool   `yaml:"enabled" mapstructure:"enabled"`
	ApiKey        string `yaml:"api_key" mapstructure:"api_key"`
	SenderName    string `yaml:"sender_name" mapstructure:"sender_name"`
	SenderAddress string `yaml:"sender_address" mapstructure:"sender_address"`
}

type Server

type Server struct {
	Logger *slog.Logger
	Config
	DataAccess
	DB *sql.DB
}

func NewServer added in v0.5.0

func NewServer(logger *slog.Logger, cfg Config, dataAccess DataAccess, db *sql.DB) (*Server, error)

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

func (*Server) SetupEcho added in v0.5.0

func (s *Server) SetupEcho(ctx context.Context, e *echo.Echo)

func (*Server) SetupEnvironment

func (s *Server) SetupEnvironment(ctx context.Context) error

func (*Server) StartBackgroundJobs

func (s *Server) StartBackgroundJobs(ctx context.Context)

Directories

Path Synopsis
api
helpers
templ: version: v0.2.707
templ: version: v0.2.707

Jump to

Keyboard shortcuts

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