Files
elegalsoftware/scripts
Leon SerfatyandClaude Fable 5 d9b807662a
CI / build-and-test (push) Has been cancelled
Add e2e auth test suite, retention crons, and email-verification UX
- E2E suite (23 tests, `npm run test:e2e -w @lawdesk/api`): boots the real
  Fastify app against a disposable Dockerized Postgres (never a real DB) and
  covers signup/login/lockout/rate limits, CSRF (incl. forged-token
  rejection), logout, password reset, email verification, the superadmin
  verified-email promotion gate, and cross-firm tenancy isolation
- packages/db: DATABASE_SSL=disable opt-out for local/test databases that
  don't speak TLS; refused in production
- retention-sweep.ts cron enforcing Privacy Policy windows (sessions,
  tokens, login attempts, tool usage, contact messages, audit log) +
  sweep-orphaned-storage.ts Spaces reconciliation + scripts/README
- Expose emailVerified on the session user; in-app verify-email banner
  with resend, and verified=1|0 toasts on the login page
- Silence Fastify logger under NODE_ENV=test; fix footer resource link;
  document login-attempt/tool-usage retention in the Privacy Policy

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 14:32:55 -04:00
..

Operational scripts

All scripts load .env from the repo root and run against the live database/bucket — there is no staging environment. Run them from the monorepo root.

Scheduled jobs (set up as daily crons on the production server)

# Daily at 03:00 — enforce Privacy Policy retention windows
0 3 * * * cd /path/to/app && npm run cron:retention >> logs/retention.log 2>&1

# Daily at 08:00 — mark past-due invoices overdue + email client reminders
0 8 * * * cd /path/to/app && npm run cron:overdue >> logs/overdue.log 2>&1
Script npm alias What it does
retention-sweep.ts npm run cron:retention Purges expired sessions, consumed/expired reset & verification tokens, login attempts and tool usage > 90 days, contact messages and audit log > 24 months.
send-overdue-reminders.ts npm run cron:overdue Flips past-due sent invoices to overdue and emails the client once, on the transition.

Maintenance / one-off

Script npm alias What it does
sweep-orphaned-storage.ts npm run storage:sweep Reconciles DO Spaces against the documents table. Dry-run by default; add -- --delete to remove orphans. Only document-shaped keys (uuid/uuid/uuid.ext) are ever deleted.
create-admin.ts Creates a superadmin user (credentials via env/argv).
seed-demo.ts Seeds demo data. Live DB — use with care.
migrate-storage-to-spaces.ts One-time migration of legacy local files to Spaces (historical).