Skip to content

Fix: Move MongoDB URI to environment variables#10

Merged
Aryan3522 merged 4 commits intoAryan3522:mainfrom
jayanth797:main
Mar 13, 2026
Merged

Fix: Move MongoDB URI to environment variables#10
Aryan3522 merged 4 commits intoAryan3522:mainfrom
jayanth797:main

Conversation

@jayanth797
Copy link
Contributor

Summary

Removed the hardcoded MongoDB connection string from the source code and replaced it with an environment-based configuration.

Changes

  • Updated Config/db.js to use mongoose.connect(process.env.MONGODB_URI)
  • Renamed environment variable from MONGO_URL to MONGODB_URI
  • Updated test scripts (test-db*.js) to use process.env.MONGODB_URI
  • Added require("dotenv").config({ path: "./Config/config.env" }) where required
  • Added Config/.env.example with placeholder values
  • Updated .gitignore to prevent committing the real environment configuration file

Result

The MongoDB URI is no longer hardcoded in the repository.
All database connections now use environment variables, improving security and configuration management.

Root Cause:
The frontend NoteCard component was already designed to display a folder icon when `note.folderId` exists. However, the Note schema did not contain `folderId` or `folderName`, so this value was always undefined.

Changes:
* Added `folderId` and `folderName` fields to the Note schema
* Updated folder controller logic to stamp these fields when a note is added to a folder
* Cleared these fields when a note is removed from a folder

Result:
Notes inside folders now correctly display the folder icon on the note card, while normal notes do not.

Tested:
* Adding note to folder -> icon appears
* Removing note from folder -> icon disappears
* Normal notes remain unchanged
@Aryan3522 Aryan3522 merged commit 1da1a45 into Aryan3522:main Mar 13, 2026
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