Setup & Lifecycle

Install thunder-core and run its setup lifecycle to create database indexes and seed default RBAC roles.

Installing the plugin only copies files and merges the import map. The setup script does not run automatically - you must trigger setup (DB indexes + RBAC seeding) explicitly.

Installing and Running Setup

--setup alone runs setup against the production environment. Pass a comma-separated list to target others:

deno task add:plugin -n Huruf-Tech/thunder-core --setup
deno task add:plugin -n Huruf-Tech/thunder-core --setup=development,production

Run setup any time after install (prompts for environments if --envs is omitted):

deno task setup:plugin -n Huruf-Tech/thunder-core
deno task setup:plugin -n Huruf-Tech/thunder-core --envs=development,production

Setup runs scripts/setupPlugin.ts once per selected environment, with ENV_TYPE set to that environment so the script connects to the correct database.

What the Lifecycle Scripts Do

ScriptResponsibility
scripts/setupPlugin.tsEntry point - calls syncDBIndexes() then syncAccessControl().
scripts/syncDBIndexes.tsCreates the plugin's MongoDB indexes and unique constraints.
scripts/syncAccessControl.tsSeeds the default RBAC policies and roles.
scripts/cleanupPlugin.tsRuns on uninstall (remove:plugin --clean).

Read scripts/syncDBIndexes.ts for the exact index definitions and unique constraints, and scripts/syncAccessControl.ts for the seeded policy permissions and role to policy mappings.

syncAccessControl inserts the default policies/roles, and the unique indexes on the access-control collections reject duplicates - so it is a one-time / fresh-database seed. Re-seed only after clearing those collections.

Before You Run Setup

Make sure the required environment variables (especially DATABASE_URL and SECRET_KEY) are set for each environment you target, since each run loads the matching .env / .env.<environment> files.


On this page