waitlist

package
v1.5.7 Latest Latest
Warning

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

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

Documentation

Overview

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

It exposes four 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, score and access
POST /v1/waitlist/boost    - service-authed position boost (e.g. hanzod)
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 and seeds any configured default waitlists. On OnServe it mounts four REST endpoints under /v1/waitlist:

POST /v1/waitlist/join     - create an entry (Turnstile + rate-limit gated)
GET  /v1/waitlist/status   - look up rank, score, share URL, access
POST /v1/waitlist/boost    - service-authed position boost (e.g. hanzod)
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 and /v1/waitlist/boost. Required
	// header is `Authorization: Bearer <AdminSecret>`. Resolved at boot from
	// WAITLIST_ADMIN_SECRET if empty. If still empty after resolution, those
	// service endpoints are disabled (404) unless the caller is a superuser.
	AdminSecret string

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

	// DefaultSlugs are waitlist slugs seeded on bootstrap. Each becomes a
	// waitlist row (name = slug with its first letter upper-cased) if absent.
	// Resolved at boot from WAITLIST_DEFAULT_SLUGS (comma-separated). Empty
	// seeds nothing.
	DefaultSlugs []string

	// AccessCapacity auto-grants product access to the top-N entries by rank.
	// Resolved at boot from WAITLIST_ACCESS_CAPACITY. Zero (default) grants
	// none automatically.
	AccessCapacity int

	// Open is the master switch that ends the waitlist: when true EVERYONE
	// has access. Resolved at boot from WAITLIST_OPEN (1/true/yes,
	// case-insensitive). Default false.
	Open bool
}

Config controls plugin registration.

Jump to

Keyboard shortcuts

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