Skip to content

feat: add environment variable validation and update documentation#23

Open
Shreenath-14 wants to merge 6 commits intoZenYukti:mainfrom
Shreenath-14:main
Open

feat: add environment variable validation and update documentation#23
Shreenath-14 wants to merge 6 commits intoZenYukti:mainfrom
Shreenath-14:main

Conversation

@Shreenath-14
Copy link

Description

Implemented a "fail-fast" environment variable validation system for the backend. Previously, the server would start with missing or malformed .env variables, leading to silent failures and a confusing developer experience. Now, the server validates all required keys (Supabase, Port, Frontend URL) upon startup and provides clear error messages if any are invalid. Closes #5.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧹 Code refactoring (no functional changes)
  • ⚡ Performance improvement
  • ✅ Test improvement
  • 🔧 Build or CI/CD configuration changes

How Has This Been Tested?

  • Startup Validation: Verified that the server crashes with a specific error message if PORT is not a number or if SUPABASE_URL is an invalid URL.

  • CORS Verification: Confirmed that updating the FRONTEND_URL in the .env correctly resolves browser console errors and allows the frontend to fetch room data.

  • Database Connectivity: Verified that valid anonymous sign-ins and message persistence work after correctly configuring Supabase keys and RLS policies.

Screenshots

image image

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional Information

Updated the CORS middleware to dynamically use the FRONTEND_URL from the environment configuration to prevent port mismatch errors between development environments (e.g., port 3000 vs 5173).

Learning Outcomes

I learned how to implement centralized configuration validation in Node.js/TypeScript and how to manage Row-Level Security (RLS) policies in Supabase for anonymous user sessions.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

ZenYukti Banner

Yay! You're officially a Contributor! 🎉

Huge thanks for opening this Pull Request. Being a contributor to ZenYukti is a big deal, and we’re excited to have you on board.

Next Steps:

  1. A maintainer will review your code soon.
  2. Please ensure you've linked an assigned issue in the description.
  3. Stay tuned for feedback!

@Shreenath-14
Copy link
Author

Hi Team ! I've implemented the environment variable validation as requested in Issue #5. I've also updated the README with a configuration table. All local tests and CI checks passed. Looking forward to your feedback!

ALTER TABLE volunteers ENABLE ROW LEVEL SECURITY;

-- Profiles policies
-- Profiles policies
Copy link
Member

Choose a reason for hiding this comment

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

Please revert these changes from this file.

because, it looks like some comments were accidentally duplicated (e.g., -- Profiles policies) nd some whitespace was changed...

we should keep this PR focused strictly on the environment variable validation to keep the git history clean

VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

# Production values:
# Production values: (if Locally running then it should be https://localhost:5000 and ws://localhost:5000 )
Copy link
Member

Choose a reason for hiding this comment

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

move the localhost examples out from under the # Production values header
it's a bit confusing for new contributors to see local URLs listed under a "Production" heading

previous one was good to me

Copy link
Member

Choose a reason for hiding this comment

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

thanks for the detailed validation logic!

I have a small style request: could we remov the numbered comments (// 1., // 2.) and the emojis (❌) from the error message?
we try to keep our backend logs as clean and standard as possible for better compatibility with different terminal and logging envirnments

it also keeps the file structure a bit more consistent with the rest of our codebase

Copy link
Author

Choose a reason for hiding this comment

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

yes sure you can remove the numerical comments

Copy link
Member

@ayushHardeniya ayushHardeniya Feb 7, 2026

Choose a reason for hiding this comment

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

you're expected to do that so that we can proceed with the PR, and kindly rebase at end

@ayushHardeniya
Copy link
Member

also why this "feat: typing indicater for better UI experience" commit is here, in thsi PR?

this is completely irrelevant as per the target of this PR!

I'd suggest you - probably rebase it, avoid "revert" or "do not merge" to keep the commit history clean for future visitors.

Copy link
Author

@Shreenath-14 Shreenath-14 left a comment

Choose a reason for hiding this comment

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

I have done the changes you told me just review it and let me know

@Shreenath-14 Shreenath-14 marked this pull request as draft February 8, 2026 07:03
@Shreenath-14 Shreenath-14 marked this pull request as ready for review February 8, 2026 07:10
@Shreenath-14 Shreenath-14 reopened this Feb 8, 2026
@Shreenath-14 Shreenath-14 marked this pull request as draft February 8, 2026 08:11
@Shreenath-14 Shreenath-14 marked this pull request as ready for review February 8, 2026 08:28
@Shreenath-14
Copy link
Author

Hi @ayushHardeniya ,
I’ve fixed the YAML syntax issues in the welcome workflow and verified that the GitHub Actions workflow is now valid.
All requested changes have been addressed.
Requesting re-review.

@ayushHardeniya
Copy link
Member

Hi @Shreenath-14, can you tell me what this PR is actually about!
You have mixed up multiple different scopes/directories into same branch?

I'd suggest to filter it out, and stick with key purpose!
You can create further PRs with respective chnages if needed.

@Shreenath-14
Copy link
Author

Sir actully this PR was my first PR thats why its been mess please ignore I'll explain.
Firstly this PR solves 2 issues :

  1. server doesn't validate environment variables server doesn't validate environment variables #5
    In this issue I have fixed the env variable verification and validation with the specific error message display on screen and if all present then check is it valid keys or not

  2. No way to tell if someone's typing No way to tell if someone's typing #8
    This is another issue assigned to me where I have implemented a typing indicator which shows is someone typing or not you can review it

also for previous you said to make some style changes which has been done and also added detailed readme changes

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.

server doesn't validate environment variables

2 participants