Skip to content

feat: add environment variable validation on server startup#61

Open
jikrana1 wants to merge 1 commit into
niharika-mente:mainfrom
jikrana1:feat/env-variable-validation
Open

feat: add environment variable validation on server startup#61
jikrana1 wants to merge 1 commit into
niharika-mente:mainfrom
jikrana1:feat/env-variable-validation

Conversation

@jikrana1

Copy link
Copy Markdown

Description

Added environment variable validation that runs on server startup, before DB and Redis connection. This ensures the server fails fast with a clear error message if any required environment variable is missing or still set to a placeholder value, instead of starting silently and failing later with cryptic errors.

Changes Made

  • Created validateEnv() function in config/validateEnv.js
  • Required vars (MONGO_URI, UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN) → if missing or placeholder, logs clear error and calls process.exit(1)
  • Optional vars (PORT) → if missing, logs a warning and server continues with default
  • Called validateEnv() in server.js after dotenv.config() and before any DB or Redis setup

Related Issue

Closes #54

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jikrana1, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 37 minutes and 57 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 34cfe1a1-c95d-4f4b-85e8-977bea1fe433

📥 Commits

Reviewing files that changed from the base of the PR and between b13fd53 and 215126c.

📒 Files selected for processing (2)
  • backend/src/config/validateEnv.js
  • backend/src/server.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

[Feature] Add environment variable validation on server startup

1 participant