mtgban-website

command module
v0.0.0-...-2896255 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 124 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

mtgban-website

The server behind mtgban.com and its sister sites: card price aggregation for Magic, Lorcana, One Piece, Yu-Gi-Oh, Riftbound, Flesh and Blood, Pokemon, Gundam and Palworld, one Go binary per game.

go build -o mtgban-website .
./mtgban-website -dev -cfg config.json
go test ./...          # needs allprintings5.json in the repo root
  • AGENTS.md: build, run, test, conventions and the invariants to keep.
  • SPECIFICATION.md: the architecture in detail.
  • deploy/README.md: how the droplets are set up and deployed.
  • docs/: design notes, and docs/adr/ for the decisions behind them.
  • todo/: plans not yet done, todo/refactor.md first.

Alert mail

Price alerts can deliver by email as well as Discord DM. The sender address is mail.from in the config (ConfigType.Mail), defaulting to BAN <no-reply@mtgban.com>; a value net/mail cannot parse is logged and fatal at startup outside -dev.

Two env vars control delivery: RESEND_API_KEY, the Resend API key for sending mail, and RESEND_WEBHOOK_SECRET, the whsec_... signing secret Resend gives a webhook endpoint (absent, the webhook answers every request 503). Production needs the key, or email stays unavailable: the email endpoints answer 503, the channel choice hides email, and alerts that chose it are parked with a notice until the key is set, when the next run resumes them. In -dev an absent key prints mail to stdout instead, and -alerts-send still gates real delivery on both channels. The mail.from domain must be verified in Resend; until it is, every send fails and is retried. Register the webhook in Resend at https://<site>/alerts/mail-events for the email.bounced and email.complained events.

The ACL property AlertChannels is a comma list of discord, email naming the delivery channels a tier may use; a tier with Alerts: true and no AlertChannels property gets discord only, for compatibility with a cookie signed before the property existed. To give a tier no channels at all, set AlertChannels to the literal string none, never an empty string: signing keeps empty values, but verification drops them, which breaks every signed page for that tier. The admin page's table and grant editors refuse one; an acl.json written by hand has to keep to it too.

AlertChannels is a new signed field, carried in the BAN_SIG signature on the cookie every site shares. Deploy this build to every site before any tier in the shared acl.json sets it: a build that predates the field rejects a signature carrying it, so a login on an updated site would sign that reader out of the rest.

Documentation

Overview

telemetry.go

Source Files

Directories

Path Synopsis
Package apihandoff is the signed token a game site hands to the API gateway when a Patreon user starts a trial or signs in.
Package apihandoff is the signed token a game site hands to the API gateway when a Patreon user starts a trial or signs in.
Package apiproductlist is the API price list: what is sold, at what amount, and under which entitlement.
Package apiproductlist is the API price list: what is sold, at what amount, and under which entitlement.
Package apisig implements the signed query blob the BAN price API accepts as ?sig=.
Package apisig implements the signed query blob the BAN price API accepts as ?sig=.
Package archidekt reads public decks from Archidekt's API.
Package archidekt reads public decks from Archidekt's API.
Package banprice holds the wire types of the price API: per-store prices and quantities keyed by grade and finish, in the exact JSON shape the endpoint has always served.
Package banprice holds the wire types of the price API: per-store prices and quantities keyed by grade and finish, in the exact JSON shape the endpoint has always served.
Package cardconduit submits cards to CardConduit's estimate API.
Package cardconduit submits cards to CardConduit's estimate API.
Package collectr reads product listings off Collectr showcase pages.
Package collectr reads product listings off Collectr showcase pages.
Package cubecobra reads public cubes from CubeCobra's JSON API.
Package cubecobra reads public cubes from CubeCobra's JSON API.
Package fuzzy provides small string-similarity helpers used to power "did you mean..." style suggestions.
Package fuzzy provides small string-similarity helpers used to power "did you mean..." style suggestions.
internal
access
Package access holds the two values a deployment enforces but does not really own: the tier access table and the Patreon grant list.
Package access holds the two values a deployment enforces but does not really own: the tier access table and the Patreon grant list.
alerts
Package alerts holds the price alert model, its Postgres store and the pure evaluator that decides when an alert fires.
Package alerts holds the price alert model, its Postgres store and the pure evaluator that decides when an alert fires.
bucketstore
Package bucketstore keeps an in-memory snapshot of a JSON document that lives in a cloud bucket, with atomic swap-on-load/save semantics.
Package bucketstore keeps an in-memory snapshot of a JSON document that lives in a cloud bucket, with atomic swap-on-load/save semantics.
bulkrates
Package bulkrates prices a card at what Cool Stuff Inc's bulk shelf pays for it, for the upload's cards no store on the page buys.
Package bulkrates prices a card at what Cool Stuff Inc's bulk shelf pays for it, for the upload's cards no store on the page buys.
currency
Package currency converts the site's USD prices into the reader's display currency: the rates snapshot, its validation, and the formatting.
Package currency converts the site's USD prices into the reader's display currency: the rates snapshot, its validation, and the formatting.
dailycap
Package dailycap caps what one client address adds in a UTC day, in memory of a fixed size.
Package dailycap caps what one client address adds in a UTC day, in memory of a fixed size.
debounce
Package debounce provides the shared burst-coalescing run loop used by background refreshers.
Package debounce provides the shared burst-coalescing run loop used by background refreshers.
diskusage
Package diskusage reports filesystem usage.
Package diskusage reports filesystem usage.
docparse
Package docparse turns uploaded inventory lists (CSV/XLS rows, decklist lines) into matched card entries.
Package docparse turns uploaded inventory lists (CSV/XLS rows, decklist lines) into matched card entries.
dsreload
Package dsreload runs one datastore reload at a time and remembers what it did, so a caller answered before the load finished can still be told.
Package dsreload runs one datastore reload at a time and remembers what it did, so a caller answered before the load finished can still be told.
embed
Package embed renders search results into share-friendly panels: the oEmbed preview served for link unfurls and the field lists Discord messages are built from.
Package embed renders search results into share-friendly panels: the oEmbed preview served for link unfurls and the field lists Discord messages are built from.
infrastructure
Package infrastructure holds the settings every deployment uses alike, filed once beside the configs rather than copied into each: the bucket keys, the Google and Patreon credentials, the uploader endpoints, the sites allowed to hand the upload a card list, and the databases.
Package infrastructure holds the settings every deployment uses alike, filed once beside the configs rather than copied into each: the bucket keys, the Google and Patreon credentials, the uploader endpoints, the sites allowed to hand the upload a card list, and the databases.
invites
Package invites holds the rules of the admin's invite links: the shape of a code, the bounds of what an admin may mint, which tiers, pages and options an invite may sign, and the state an invite is in (docs/adr/0011-invite-links.md).
Package invites holds the rules of the admin's invite links: the shape of a code, the bounds of what an admin may mint, which tiers, pages and options an invite may sign, and the state an invite is in (docs/adr/0011-invite-links.md).
jobs
Package jobs records what the site's background jobs did: when each last ran and for how long, whether that run panicked, what the job reported finding and what is wrong with it, and whether a scheduled one has missed its time.
Package jobs records what the site's background jobs did: when each last ran and for how long, whether that run panicked, what the job reported finding and what is wrong with it, and whether a scheduled one has missed its time.
metricsreport
Package metricsreport holds the admin Metrics section's rules and the cache of the queries behind them.
Package metricsreport holds the admin Metrics section's rules and the cache of the queries behind them.
mkmidparser
Package mkmidparser resolves a Cardmarket product id to the card it names.
Package mkmidparser resolves a Cardmarket product id to the card it names.
natcmp
Package natcmp compares strings naturally: runs of digits by their value, everything else byte by byte.
Package natcmp compares strings naturally: runs of digits by their value, everything else byte by byte.
notify
Package notify delivers one-line messages to Discord webhooks.
Package notify delivers one-line messages to Discord webhooks.
offline
Package offline implements the offline mode price payload format, per user watermarking, and per set change fingerprints.
Package offline implements the offline mode price payload format, per user watermarking, and per set change fingerprints.
offlineapi
Package offlineapi serves the offline PWA data endpoints as a dependency-injected service following the same pattern as internal/palette.
Package offlineapi serves the offline PWA data endpoints as a dependency-injected service following the same pattern as internal/palette.
palette
Package palette serves the command-palette data endpoints and nav-target lists: set/store/card/sealed metadata the palette's filter builder and jump actions are built from.
Package palette serves the command-palette data endpoints and nav-target lists: set/store/card/sealed metadata the palette's filter builder and jump actions are built from.
phyrexian
Package phyrexian respells Phyrexian card names for the Phi normal font.
Package phyrexian respells Phyrexian card names for the Phi normal font.
pledge
Package pledge turns a Patreon login into a reader and the site tier their pledge, or a grant, entitles them to: who Patreon says the reader is, which tier title its membership answer names, and which of the site's tiers that is.
Package pledge turns a Patreon login into a reader and the site tier their pledge, or a grant, entitles them to: who Patreon says the reader is, which tier title its membership answer names, and which of the site's tiers that is.
poke
Package poke keeps what makes a signature stale before its age does: when each poked reader was poked, when the access table last changed, and when each grantee's grant did.
Package poke keeps what makes a signature stale before its age does: when each poked reader was poked, when the access table last changed, and when each grantee's grant did.
salesvelocity
Package salesvelocity reads TCGplayer's copies sold a day per card from the newspaper's sales table, holds the last load, and watches the pull behind it.
Package salesvelocity reads TCGplayer's copies sold a day per card from the newspaper's sales table, holds the last load, and watches the pull behind it.
sessionstore
Package sessionstore turns an uploaded list into a scraper an admin can publish for the current process, and tracks which of the served scrapers were installed that way.
Package sessionstore turns an uploaded list into a scraper an admin can publish for the current process, and tracks which of the served scrapers were installed that way.
siteorigin
Package siteorigin says which public origin a request reached the site at, behind the proxy, and whether a host is one of the site's own.
Package siteorigin says which public origin a request reached the site at, behind the proxy, and whether a host is one of the site's own.
storeorder
Package storeorder lays an optimizer table out in the order its store's buylist invoice lists cards, so the pile pulled top to bottom matches the invoice every store asks cards to be shipped in.
Package storeorder lays an optimizer table out in the order its store's buylist invoice lists cards, so the pile pulled top to bottom matches the invoice every store asks cards to be shipped in.
suggest
Package suggest builds the names the browser's suggestion bar offers through OpenSearch, and the "did you mean..." and alternative-search hints for queries that return no results.
Package suggest builds the names the browser's suggestion bar offers through OpenSearch, and the "did you mean..." and alternative-search hints for queries that return no results.
tcgcatalog
Package tcgcatalog parses the catalog dumps produced by tcgdumper (github.com/mtgban/go-tcgplayer).
Package tcgcatalog parses the catalog dumps produced by tcgdumper (github.com/mtgban/go-tcgplayer).
tcgskuparser
Package tcgskuparser resolves a TCGplayer SKU to the card it names and the condition it encodes.
Package tcgskuparser resolves a TCGplayer SKU to the card it names and the condition it encodes.
tmplparse
Package tmplparse parses HTML template files with the indentation they are written with stripped out.
Package tmplparse parses HTML template files with the indentation they are written with stripped out.
uploadsort
Package uploadsort holds what the upload page's rows sort by when the reader breaks ties by card properties: one string per property, written on each row, which the page's sorter compares as it stands.
Package uploadsort holds what the upload page's rows sort by when the reader breaks ties by card properties: one string per property, written on each row, which the page's sorter compares as it stands.
uploadtie
Package uploadtie decides which store wins when several offer the same best price on an upload row, by the rule the reader picked in the upload settings.
Package uploadtie decides which store wins when several offer the same best price on an upload row, by the rule the reader picked in the upload settings.
xlsread
Package xlsread reads the cell text of a legacy Excel workbook (.xls), BIFF8 or BIFF5, from bytes already in memory.
Package xlsread reads the cell text of a legacy Excel workbook (.xls), BIFF8 or BIFF5, from bytes already in memory.
xlsread/xlstest
Package xlstest writes small .xls files for tests: no .xls writer exists in the module graph, and the tests would otherwise need binary fixtures.
Package xlstest writes small .xls files for tests: no .xls writer exists in the module graph, and the tests would otherwise need binary fixtures.
Package mailer sends mail for the site and the API gateway: one interface, SMTP (STARTTLS or implicit TLS), Resend over HTTP, and a logging mailer for tests.
Package mailer sends mail for the site and the API gateway: one interface, SMTP (STARTTLS or implicit TLS), Resend over HTTP, and a logging mailer for tests.
Package manabox reads public decks from ManaBox's cloud API.
Package manabox reads public decks from ManaBox's cloud API.
Package moxfield reads decks and collections off Moxfield's API.
Package moxfield reads decks and collections off Moxfield's API.
Package mythictools reads public collection lists from Mythic Tools.
Package mythictools reads public collection lists from Mythic Tools.
Package observability records page visits in Postgres and answers the admin dashboard's usage aggregates.
Package observability records page visits in Postgres and answers the admin dashboard's usage aggregates.
Package patreon holds the OAuth client behind the site's Patreon login.
Package patreon holds the OAuth client behind the site's Patreon login.
Package ratelimit throttles requests per key (a visitor IP, an email).
Package ratelimit throttles requests per key (a visitor IP, an email).
scripts
gen-ofp1-fixture command
Command gen-ofp1-fixture writes OFP1 fixtures that pin the Go encoder and the JS decoder to the same bytes.
Command gen-ofp1-fixture writes OFP1 fixtures that pin the Go encoder and the JS decoder to the same bytes.
Package timeseries keeps price history in Postgres and answers the chart and mover queries the site draws from it.
Package timeseries keeps price history in Postgres and answers the chart and mover queries the site draws from it.
Package userstate persists per-user preferences and entitlements in Postgres, keyed by a hash of the login email.
Package userstate persists per-user preferences and entitlements in Postgres, keyed by a hash of the login email.

Jump to

Keyboard shortcuts

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