app

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

Package app wires the stores, services and API handlers into one Echo server, and serves the web client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Echo *echo.Echo
	// contains filtered or unexported fields
}

App is a wired server.

func Build

func Build(conf Config, s Stores, objects upload.Storage, mailer *mail.MailerInit) *App

Build wires everything without connecting to anything, so tests can pass fakes. Background work starts in Start.

func New

func New(conf Config) *App

New connects to Postgres and S3 and builds the server.

func (*App) Start

func (a *App) Start() error

Start begins background work and serves until the server stops.

func (*App) Stop

func (a *App) Stop()

Stop ends background work.

type Config

type Config struct {
	Address      string
	DomainName   string
	DatabaseURL  string
	DatabaseHost string
	Version      string
	Session      auth.Config
	S3           storage.Config
	Mail         mail.Config
	Passwords    auth.PasswordConfig
	Redis        auth.RedisConfig
	// UI is the built React client (index.html + assets/); nil means not built.
	UI fs.FS
	// UIProxy, when set, proxies every non-API page to the Vite dev server instead of UI.
	UIProxy *url.URL
	// MTLS, when set, serves over TLS and only accepts requests from allowed client certificates.
	MTLS *mtls.Server
	// TrustedProxies are the reverse proxies whose X-Forwarded-For is
	// believed. Empty means the connecting address is the client's.
	TrustedProxies []*net.IPNet
	// FileRetention is how long a file may go unreferenced before the daily
	// file check deletes it; zero means filecheck.MaxRetention (30 days).
	FileRetention time.Duration
}

Config is everything the server needs, loaded from the environment by main.

type Stores

type Stores struct {
	Affiliation *affiliation.Store
	Document    *document.Store
	FileCheck   *filecheck.Store
	Image       *image.Store
	News        *news.Store
	Player      *player.Store
	Programme   *programme.Store
	Setting     *setting.Store
	Sponsor     *sponsor.Store
	Team        *team.Store
	User        *user.Store
	WhatsOn     *whatson.Store
}

Stores are the database repositories.

func NewStores

func NewStores(db *sqlx.DB) Stores

NewStores builds every repository over one connection pool.

Jump to

Keyboard shortcuts

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