waitlist

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package waitlist registers a viral waiting-list plugin on a Base app.

It exposes three endpoints under /v1/waitlist:

POST /v1/waitlist/join     - register an entry, optionally crediting a referrer
GET  /v1/waitlist/status   - look up an entry's rank and share URL
GET  /v1/waitlist/export   - admin-only CSV export

Backing storage is two Base collections (`waitlists`, `waitlist_entries`) that are auto-created on bootstrap. All state lives in the host Base SQLite shard — no Redis, no external store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustRegister

func MustRegister(app core.App, cfg Config)

MustRegister installs the waitlist plugin on the given app and panics on error. Suitable for use in a Base process's startup wiring.

func Register

func Register(app core.App, cfg Config) error

Register installs the waitlist plugin.

On OnBootstrap the plugin auto-creates two collections (`waitlists`, `waitlist_entries`) if they don't exist. On OnServe it mounts three REST endpoints under /v1/waitlist:

POST /v1/waitlist/join     - create an entry (Turnstile + rate-limit gated)
GET  /v1/waitlist/status   - look up rank, share URL, referral count
GET  /v1/waitlist/export   - admin-only CSV dump

The plugin owns its collections and never exposes them as direct CRUD — the dashboard remains available for admins.

Types

type Config

type Config struct {
	// Enabled toggles the whole plugin. Default: true.
	Enabled bool

	// CollectionPrefix lets multiple waitlist plugins coexist on one Base
	// (rare). Default empty -> collections named `waitlists` and `waitlist_entries`.
	CollectionPrefix string

	// TurnstileSecret enables Cloudflare Turnstile token verification on
	// /v1/waitlist/join. Leave empty in dev to skip verification.
	// Resolved at boot from TURNSTILE_SECRET_KEY if empty.
	TurnstileSecret string

	// JoinRateLimit caps /v1/waitlist/join by source IP. Zero -> default
	// (5 per hour). Set negative to disable.
	JoinRateLimit int

	// JoinRateWindow is the sliding window for JoinRateLimit. Zero -> 1h.
	JoinRateWindow time.Duration

	// AdminSecret guards /v1/waitlist/export. Required header is
	// `Authorization: Bearer <AdminSecret>`. Resolved at boot from
	// WAITLIST_ADMIN_SECRET if empty. If still empty after resolution,
	// export is disabled (404).
	AdminSecret string

	// DisposableDomains, if non-nil, replaces the built-in disposable
	// e-mail blocklist. Pass an empty slice to disable blocking.
	DisposableDomains []string
}

Config controls plugin registration.

Jump to

Keyboard shortcuts

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