Skip to content
Early bird + Black Friday · 73% off

Get ZeroDirs for $179 $49

Claim $49 deal

Admin

/admin/ is the review queue and the deployment’s state: a Worker route on the DB binding Go live creates, open to the accounts named in admin.emails. An admin is an account: you sign in on /login/ like any submitter — email and password, or Google — and open /admin/.

  1. Name the admins.

    site.config.ts
    features: { submissions: true, accounts: true },
    admin: { emails: ['you@acme.com'] },

    Accounts have to be on — pnpm check:config says features.accounts … must be true while admin.emails names anyone otherwise. admin.email (singular) is a different field: where the operator’s notifications go, else site.contactEmail.

  2. Set the signing secret — pnpm cf:setup generates and uploads it; to rotate it by hand:

    Terminal
    pnpm cf:secrets TOKEN_SECRET

    The value comes from .env.prod, 32 characters or more; node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))" makes one.

  3. Deploy, then sign in with a proven address.

    Terminal
    pnpm deploy

    Open https://<your domain>/admin/: it sends you to /login/. Sign in with Google, or ask for a password-reset link on /login/forgot/ and open it — either proves the address is yours, and /admin/ opens. A password typed into /signup/ alone does not: signing up checks nothing, so /admin/ answers “Prove this address first” until Google or the link has been through.

What to check Where You should see
The gate /admin/, signed out a 302 to /login/?next=%2Fadmin%2F
Who gets in /admin/, signed in as a listed, proven address the review queue, your address beside Sign out
Who does not /admin/, signed in as anybody else 403 at /admin/login/: “Not an admin”, with the address and the fix
The report /admin/ a “Configuration” card, or none
The jobs Workers & Pages → your Worker → Logs one jobs: … line an hour

The admin dashboard: rebuild bar, configuration report, queue numbers

  • Locally it is the same: put your address in admin.emails, run pnpm dev, and sign in with Google (GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET in .env), or sign up with a password and prove the address with the reset link providers.email: 'console' prints in the terminal.
  • A signed-in admin’s account menu and dashboard sidebar carry an Admin entry; nobody else’s do. /admin/ is still checked on every request — the entry is a convenience, not the guard.
  • Read the “Configuration” card after every deploy — each state is silent otherwise. error: on and broken — Missing secret DEPLOY_HOOK_URL — run: wrangler secret put DEPLOY_HOOK_URL (local: add to .env); warning: lossy (providers.rebuild is "none", so approvals never reach the site).
  • Approve takes an optional slug; Reject… needs a reason of three characters or more, emailed verbatim, and “Awaiting payment” rows cannot be approved. Delete refuses a paid row and takes its R2 objects with it; Mark as paid by hand writes a manual: payments row, Resend the status email flushes the outbox.
  • /admin/listings/?q=&status=&tier=&page= browses everything and bookmarks. One listing (/admin/listings/<id>/) previews through the real normaliser, so a category dropped from site.config.ts reads “This row cannot be rendered yet”.
  • Sign out on /admin/ ends the account’s session on the whole site; each write leaves an audit_log row.

A submission under review: preview, slug, approve and reject

One cron trigger, 0 * * * * in wrangler.jsonc, runs runJobs() in this order.

Job What it does
expireFeatured demotes a closed paid window, asks a rebuild
adminDigest queues the daily reminder at queue.digestHourUtc while anything waits
flushOutbox sends up to 20 queued messages, five attempts each
retryRebuilds refires the oldest failed build
purgeUnpaid deletes submissions unpaid past limits.unpaidTtlDays
sweepAuth with features.accounts, deletes expired sessions and password-reset links
jobs: expireFeatured=0 flushOutbox=2 retryRebuilds=0 purgeUnpaid=0 adminDigest=0 (cron=0 * * * *, in 41ms)

pnpm exec wrangler tail streams it; skipped: no DB binding, emailFailures=<n> and errors: … join it only when relevant. Locally: pnpm build, pnpm exec wrangler dev, then curl "http://localhost:8787/cdn-cgi/local/scheduled?cron=0+*+*+*+*" — under pnpm dev that URL is the 404 page.

State Visitor sees /admin/ reports Fix
Signed out 302 to /login/?next=… — sign in
Signed in, not listed 403 “Not an admin” at /admin/login/ — add the address to admin.emails, deploy
Listed, not proven 403 “Prove this address first” — sign in with Google, or open a reset link
admin.emails empty “Admin is not set up” at /admin/login/ error: admin.emails is empty: nobody can sign in to /admin/ (pnpm cf:doctor says the same) name an address, deploy
TOKEN_SECRET missing status and checkout links cannot be signed; /submit/ refuses error: nothing can be signed pnpm cf:secrets TOKEN_SECRET
TOKEN_SECRET is the example value every link is forgeable error: “still the value from .env.example” generate a value, upload it
triggers missing from wrangler.jsonc nothing expires, mail waits no jobs: line restore the cron, deploy

admin.emails, admin.email and providers.adminNotify — admin, providers.

  • Directorysrc/
    • Directorypages/admin/ login.astro is the page that says why /admin/ is shut
      • …
    • Directorytemplates/admin/
      • …
    • Directorycomponents/admin/ ConfigGaps, RebuildBar, QueueTable, ListingForms
      • …
    • layouts/Admin.astro
    • actions/admin.ts
    • middleware.ts the guard
    • Directoryserver/
      • admin-auth.ts isAdminEmail(), adminAccess()
      • audit.ts
      • queries.ts
      • secrets.ts configGaps()
      • jobs.ts runJobs()
    • worker.ts scheduled()
  • scripts/dev-setup.ts
  • wrangler.jsonc the cron trigger
  • tests/e2e/admin.spec.ts the gate, the queue, an approval, in a browser