-
Notifications
You must be signed in to change notification settings - Fork 0
Data and Environments
willianpm edited this page Mar 14, 2026
·
1 revision
Environment is selected by APP_ENV:
- prod (default)
- staging
Data directory is resolved as:
- data/environments/prod
- data/environments/staging
Each environment keeps the same file set:
- active-polls.json
- draft-polls.json
- mensalistas.json
- role-bindings.json
- criadores-internos.json
- historico-votacoes.json
The file handler guarantees initialization and read/write consistency.
In memory structures:
- client.activePolls: map of active poll messageId -> poll object
- client.draftPolls: map of draft id -> draft object
Persistence model:
- Runtime changes are persisted to JSON files on updates.
- Startup reloads JSON into runtime maps.
During boot sequence:
- Missing files are created.
- Active polls are normalized for compatibility.
- Drafts older than 90 days are deleted.
- Reactions are synchronized to recover state after downtime.
- Vote-limit violations are corrected.
Legacy data migration script:
npm run migrate:data