Skip to content
Open

main #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions mern/backend/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion mern/backend/db/connection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MongoClient, ServerApiVersion } from "mongodb";

const URI = "mongodb://mongodb:27017";
const URI = "mongodb+srv://akhileshyalapalli266:Akhilesh266@akhileshdb.naco49j.mongodb.net/?retryWrites=true&w=majority&appName=AkhileshDB";
const client = new MongoClient(URI, {
Comment on lines +3 to 4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove hard-coded MongoDB credentials – move URI to environment variables.

Committing the full Atlas connection string (including username & password) to version control is a severe security risk. Anyone with repo access (or even a leaked patch) can obtain full database access.

-import { MongoClient, ServerApiVersion } from "mongodb";
+import { MongoClient, ServerApiVersion } from "mongodb";
+import dotenv from "dotenv";
+
+dotenv.config();               // Loads .env variables

-const URI = "mongodb+srv://akhileshyalapalli266:Akhilesh266@akhileshdb.naco49j.mongodb.net/?retryWrites=true&w=majority&appName=AkhileshDB";
+const URI = process.env.MONGODB_URI;
+
+if (!URI) {
+  throw new Error(
+    "MONGODB_URI is not set – define it in your environment or .env file",
+  );
+}

Be sure to

  1. Add .env (or your secret-manager setup) containing MONGODB_URI, and
  2. List .env in .gitignore to keep it out of the repo.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const URI = "mongodb+srv://akhileshyalapalli266:Akhilesh266@akhileshdb.naco49j.mongodb.net/?retryWrites=true&w=majority&appName=AkhileshDB";
const client = new MongoClient(URI, {
import { MongoClient, ServerApiVersion } from "mongodb";
import dotenv from "dotenv";
dotenv.config(); // Loads .env variables
const URI = process.env.MONGODB_URI;
if (!URI) {
throw new Error(
"MONGODB_URI is not set – define it in your environment or .env file",
);
}
const client = new MongoClient(URI, {
// … your existing options here, e.g.:
// serverApi: ServerApiVersion.v1,
});
🤖 Prompt for AI Agents
In mern/backend/db/connection.js around lines 3 to 4, the MongoDB connection URI
is hard-coded with credentials, which is a security risk. Remove the hard-coded
URI and instead load it from an environment variable like
process.env.MONGODB_URI. Ensure you add a .env file containing MONGODB_URI with
the connection string and include .env in .gitignore to prevent committing
sensitive information to the repository.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

great!! thanks for this

serverApi: {
version: ServerApiVersion.v1,
Expand Down
23 changes: 0 additions & 23 deletions mern/frontend/Dockerfile

This file was deleted.