Skip to content

feat: add dotenv support for environment configuration#131

Merged
Sing-Li merged 1 commit intoRocketChat:masterfrom
amitb0ra:feature/env-support
Mar 26, 2026
Merged

feat: add dotenv support for environment configuration#131
Sing-Li merged 1 commit intoRocketChat:masterfrom
amitb0ra:feature/env-support

Conversation

@amitb0ra
Copy link
Copy Markdown
Contributor

Summary

Add dotenv support to load static/secret configuration from .env files, as discussed in #128.

This is a standalone env support PR — no test code or other refactors are mixed in.

What changed

Static config → .env (via dotenv)

Secrets and environment-specific settings are now loaded from a .env file:

  • AUTH_TOKEN — GitHub personal access token
  • ORGANIZATION — GitHub org name
  • ORGANIZATION_HOMEPAGE — org homepage URL
  • ORGANIZATION_GITHUB_URL — org GitHub URL
  • ADMIN_PASSWORD — admin panel password
  • SERVER_PORT — backend API port (default: 62050)

Dynamic config → config.json (unchanged)

Runtime values that the admin panel modifies stay in config.json:

  • delay, contributors, startDate, includedRepositories

Test isolation support

  • Path overrides: CONFIG_PATH, DATA_PATH, LOG_PATH, ADMINDATA_PATH, DATA_BASE_PATH, CONFIG_BACKUP_PATH — tests can point these at fixture files
  • LEADERBOARD_SKIP_REFRESH=1 — disables the refresh.js child process spawn so tests can start the server without hitting the GitHub API
  • module.exports = { server } — allows tests to import the server programmatically

New files

  • src/server/.env.example — template with all supported env vars

Updated files

  • src/server/app.js — dotenv loading, env vars for static config, path overrides, skip-refresh guard, server export
  • src/server/refresh.js — dotenv loading, env vars for paths and organization
  • src/server/util/API.js — uses process.env.AUTH_TOKEN directly, startDate passed as parameter
  • src/server/config-example.json — stripped of static fields (only dynamic values remain)
  • src/server/package.json — added dotenv dependency
  • .gitignore — added .env
  • AGENTS.md, README.md, GEMINI.md — updated setup instructions and config reference

Setup (after this PR)

cp src/server/config-example.json src/server/config.json
cp src/server/.env.example src/server/.env
# Edit .env with your GitHub token, org, admin password
# Edit config.json with your contributors list (ships with defaults)

Related PRs

Copy link
Copy Markdown
Member

@Sing-Li Sing-Li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove anything that is not related to dotenv support. We don't need it on this PR.

Comment thread src/server/app.js Outdated
Comment thread src/server/app.js Outdated
Comment thread src/server/package-lock.json
- Add dotenv to load static/secret config from .env file
- Move AUTH_TOKEN, ORGANIZATION, ADMIN_PASSWORD, SERVER_PORT, and
  URL settings from config.json to environment variables
- Keep dynamic runtime values (contributors, delay, startDate,
  includedRepositories) in config.json for admin panel modification
- Add .env.example template with all supported variables
- Add path overrides (CONFIG_PATH, DATA_PATH, etc.) for flexibility
- Update config-example.json to contain only dynamic values
- Add .env to .gitignore
- Update documentation (README, AGENTS.md, GEMINI.md)
@amitb0ra amitb0ra force-pushed the feature/env-support branch from 422b03a to 4a26dbc Compare March 26, 2026 03:35
@amitb0ra amitb0ra requested a review from Sing-Li March 26, 2026 03:37
Copy link
Copy Markdown
Member

@Sing-Li Sing-Li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Sing-Li Sing-Li merged commit 2efa98a into RocketChat:master Mar 26, 2026
1 check passed
@amitb0ra amitb0ra deleted the feature/env-support branch April 1, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants