lib

package
v0.0.0-...-a46d881 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmailPass = "Email"

	DBHost = "Host"

	DBUsername = "User"

	DBPass = "Pass"

	DBPort = "Port"

	Development = "Development"

	WebAdminUser = "WebAdminUser"

	WebAdminPass = "WebAdminPass"

	RecaptchaSecret = "RecaptchaSecret"

	CSRFSecret = "CSRFSecret"
)

ToDo: This is probably complex enough to warrant a file now...

View Source
const (
	InsertRSVP  = `INSERT INTO rsvp (content, ctime) VALUES (?, ?)`
	GetAllRSVPs = `SELECT id, content, ctime FROM rsvp`
	DeleteRSVP  = `DELETE FROM rsvp where id = ?`
)
View Source
const (
	None = DinnerType(iota)
	BeefShortRib
	HoneySalmon
	Vegetarian
	Vegan
)

ToDo - the dinners should probably be in their own DB table...but this will do

Variables

This section is empty.

Functions

func Verify

func Verify(log *zap.Logger, recaptchaSecret, userRespToken, userIp string) (bool, error)

Types

type Config

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

func NewConfig

func NewConfig() (*Config, error)

func (*Config) Get

func (c *Config) Get(key string) (string, error)

func (*Config) Populate

func (c *Config) Populate() error

func (*Config) Set

func (c *Config) Set(key, value string)

type DBClient

type DBClient struct {
	Db *sqlx.DB
	// contains filtered or unexported fields
}

func NewDBClient

func NewDBClient(cfg *Config, log *zap.Logger) (*DBClient, error)

func (*DBClient) CheckConnection

func (d *DBClient) CheckConnection() error

type DBError

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

func NewDBError

func NewDBError(query string, innerErr error) *DBError

func (*DBError) Error

func (d *DBError) Error() string

type DinnerType

type DinnerType int

func (DinnerType) IsValid

func (d DinnerType) IsValid(isAttending bool) bool

func (DinnerType) ToString

func (d DinnerType) ToString() string

type PlusOne

type PlusOne struct {
	Name         string     `json:"name"`
	DinnerChoice DinnerType `json:"dinner_choice"`
	IsAttending  bool       `json:"is_attending"`
}

func (*PlusOne) Validate

func (p *PlusOne) Validate() error

type RSVP

type RSVP struct {
	Id           int        `json:"id"`
	Name         string     `json:"name"`
	Email        string     `json:"email"`
	IsAttending  bool       `json:"is_attending"`
	DinnerChoice DinnerType `json:"dinner_choice"`
	Comments     string     `json:"comments,omitempty"`
	Guests       []*PlusOne `json:"guests,omitempty"`
	WantsAccomm  bool       `json:"accommodations"`
}

func (*RSVP) BothAttending

func (r *RSVP) BothAttending() bool

func (*RSVP) Validate

func (r *RSVP) Validate() error

type RSVPProvider

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

func NewRSVPProvider

func NewRSVPProvider(client *DBClient) *RSVPProvider

func (*RSVPProvider) Add

func (r *RSVPProvider) Add(ctx context.Context, toAdd *RSVP) error

func (*RSVPProvider) GetAll

func (r *RSVPProvider) GetAll(ctx context.Context) ([]*RSVP, error)

func (*RSVPProvider) Remove

func (r *RSVPProvider) Remove(ctx context.Context, id int) error

type RSVPRow

type RSVPRow struct {
	Id      int       `db:"id"`
	Content string    `db:"content"`
	CTime   time.Time `db:"ctime"`
}

type RecaptchaResponse

type RecaptchaResponse struct {
	Success     bool     `json:"success"`
	ChallengeTS string   `json:"challenge_ts"`
	Hostname    string   `json:"hostname"`
	ErrorCodes  []string `json:"error-codes"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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