Skip to content

Scheduled Tasks

NuxtBase includes maintenance tasks under server/tasks/*.

These tasks are part of the product’s operational layer. They are useful once the app is live, but they are not all-on by magic. You still need to wire them into your deployment or scheduler.

  • demo:cleanup: removes stale demo business data older than 24 hours
  • ai:reconcile: voids stale pending AI settlements and refunds reserved credits
  • billing:repair-orphan-plans: repairs orphan Stripe billing plans by re-linking prices and subscriptions

demo:cleanup is designed for public demo environments.

Important behavior:

  • it only runs when NUXT_PUBLIC_DEMO_MODE=true
  • it deletes business data older than 24 hours
  • it does not target auth tables
  • it removes dependent records in a safe order

The current cleanup task targets records such as:

  • project data
  • file assets and attachment refs
  • AI conversations and messages
  • AI usage ledger entries
  • audit logs

ai:reconcile exists to clean up stale pending AI settlements.

If a pending settlement sits around too long, the task:

  • voids it
  • refunds reserved credits back to the wallet

That keeps wallet balances from staying artificially reduced after interrupted or failed AI request flows.

billing:repair-orphan-plans is an operational repair task.

It looks for billing plans that lost their canonical planKey, then tries to:

  1. resolve the right plan from known Stripe price IDs
  2. relink local billing prices
  3. relink local subscriptions

This is not a task most buyers run every day, but it is part of the shipped maintenance toolkit.

The template gives you the task definitions, but not a production scheduler opinion.

In practice, you should decide:

  • which tasks run in development only
  • which tasks run in production
  • how often they run
  • where logs and alerts go when a task starts failing