Skip to content

Commit 7ba0c02

Browse files
committed
misc: some comments updated
1 parent f1453f8 commit 7ba0c02

4 files changed

Lines changed: 19 additions & 38 deletions

File tree

‎backend/app.js‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if (process.env.NODE_ENV !== 'test') {
4646
}
4747

4848

49-
// IMPORTS
49+
// rate limiter and loggerr IMPORTS
5050
const { limiter, logger } = require('./middleware/api_usage');
5151

5252
// Route Imports
@@ -59,11 +59,7 @@ const storageRoute = require('./routes/storage');
5959
// ROUTES SETUP
6060
app.use('/api/auth', dashboardLimiter, authRoute); // Developer Auth
6161
app.use('/api/projects', dashboardLimiter, projectRoute); // Project Mgmt
62-
63-
// Logger added to userAuth route
6462
app.use('/api/userAuth', limiter, logger, userAuthRoute);
65-
66-
// Data & Storage Routes (Protected)
6763
app.use('/api/data', limiter, cors(adminCorsOptions), logger, dataRoute);
6864
app.use('/api/storage', limiter, cors(adminCorsOptions), logger, storageRoute);
6965

@@ -72,7 +68,7 @@ app.get('/', (req, res) => {
7268
res.status(200).json({ status: "success", message: "urBackend API is running 🚀" })
7369
});
7470

75-
// FAULT TOLERANCE: Global Error Handler
71+
// Global Error Handler
7672
app.use((err, req, res, next) => {
7773
if (err instanceof SyntaxError && err.status === 400 && 'body' in err) {
7874
return res.status(400).json({
@@ -87,7 +83,7 @@ app.use((err, req, res, next) => {
8783
message: err.message
8884
});
8985
});
90-
// DB CONNECTION & SERVER START
86+
// DB and server initialization
9187
// (Only connect if NOT in Test Mode)
9288
if (process.env.NODE_ENV !== 'test') {
9389

@@ -121,7 +117,7 @@ if (process.env.NODE_ENV !== 'test') {
121117
console.log(`Server running on port ${PORT}`);
122118
});
123119

124-
// 🛡️ GRACEFUL SHUTDOWN
120+
// handle gracefll shutdwn
125121
const gracefulShutdown = async () => {
126122
console.log('🛑 SIGTERM/SIGINT received. Shutting down gracefully...');
127123

‎backend/controllers/data.controller.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const Project = require("../models/Project");
44
const { getConnection } = require("../utils/connection.manager");
55
const { getCompiledModel } = require("../utils/injectModel");
66

7-
// Helper: CodeQL ko satisfy karne ke liye ID validate karna zaroori hai
7+
// Validate MongoDB ObjectId
88
const isValidId = (id) => mongoose.Types.ObjectId.isValid(id);
99

10-
// 1. INSERT DATA
10+
// INSERT DATA
1111
module.exports.insertData = async (req, res) => {
1212
try {
1313
const { collectionName } = req.params;
@@ -38,7 +38,7 @@ module.exports.insertData = async (req, res) => {
3838
}
3939
}
4040

41-
// Sanitize removes MongoDB operators like $ne, $gt etc.
41+
// Prevnt NoSQL injection
4242
const safeData = sanitize(cleanData);
4343

4444
let docSize = 0;
@@ -65,7 +65,7 @@ module.exports.insertData = async (req, res) => {
6565
}
6666
};
6767

68-
// 2. GET ALL DATA
68+
// GET ALL DATA
6969
module.exports.getAllData = async (req, res) => {
7070
try {
7171
const { collectionName } = req.params;
@@ -84,13 +84,13 @@ module.exports.getAllData = async (req, res) => {
8484
}
8585
};
8686

87-
// 3. GET SINGLE DOC
87+
// GET SINGLE DOC
8888
module.exports.getSingleDoc = async (req, res) => {
8989
try {
9090
const { collectionName, id } = req.params;
9191
const project = req.project;
9292

93-
// CodeQL Fix: User input ID ko pehle validate karo
93+
// ensure valid mongose objct id
9494
if (!isValidId(id)) return res.status(400).json({ error: "Invalid ID format." });
9595

9696
const collectionConfig = project.collections.find(c => c.name === collectionName);
@@ -108,7 +108,7 @@ module.exports.getSingleDoc = async (req, res) => {
108108
}
109109
};
110110

111-
// 4. UPDATE DATA
111+
// UPDATE DATA
112112
module.exports.updateSingleData = async (req, res) => {
113113
try {
114114
const { collectionName, id } = req.params;
@@ -149,7 +149,7 @@ module.exports.updateSingleData = async (req, res) => {
149149
}
150150
};
151151

152-
// 5. DELETE DATA
152+
// DELETE DATA
153153
module.exports.deleteSingleDoc = async (req, res) => {
154154
try {
155155
const { collectionName, id } = req.params;

‎backend/utils/injectModel.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,30 @@ function getCompiledModel(connection, collectionData, projectId, isExternal) {
3434
}
3535

3636

37-
// 1. Get per-connection cache
37+
// Get per-connection cache
3838
if (!modelRegistry.has(connection)) {
3939
modelRegistry.set(connection, new Map());
4040
}
4141

4242
const connectionModels = modelRegistry.get(connection);
4343

44-
// 2. If already compiled for THIS connection
44+
// If already compiled for THIS connection
4545
if (connectionModels.has(collectionName)) {
4646
return connectionModels.get(collectionName);
4747
}
4848

49-
// 3. If model already exists on connection (edge case)
49+
// If model already exists on connection (edge case)
5050
if (connection.models[collectionName]) {
5151
const existingModel = connection.models[collectionName];
5252
connectionModels.set(collectionName, existingModel);
5353
return existingModel;
5454
}
5555

56-
// 4. Build schema + compile
56+
// Build schema + compile
5757
const schema = buildMongooseSchema(collectionData.model);
5858
const model = connection.model(collectionName, schema);
5959

60-
// 5. Cache it
60+
// Cache it
6161
connectionModels.set(collectionName, model);
6262

6363
return model;

‎frontend/src/App.jsx‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,12 @@ import CreateCollection from './pages/CreateCollection';
1212
import NotFound from './pages/NotFound';
1313
import Analytics from './pages/Analytics';
1414

15-
// 1. Import Database Page
1615
import Database from './pages/Database';
17-
18-
// 2. Import Storage Page
1916
import Storage from './pages/Storage';
20-
21-
// 3. Import Docs Page
2217
import Docs from './pages/Docs';
23-
2418
import Auth from './pages/Auth';
2519
import OtpVerification from './pages/OtpVerification';
26-
27-
2820
import Settings from './pages/Settings';
29-
3021
import ProjectSettings from './pages/ProjectSettings';
3122

3223

@@ -77,7 +68,6 @@ function App() {
7768
</ProtectedRoute>
7869
} />
7970

80-
{/* 2. Database Route */}
8171
<Route path="/project/:projectId/database" element={
8272
<ProtectedRoute>
8373
<MainLayout>
@@ -86,15 +76,14 @@ function App() {
8676
</ProtectedRoute>
8777
} />
8878

89-
{/* 2. Register Storage Route */}
9079
<Route path="/project/:projectId/storage" element={<ProtectedRoute><MainLayout><Storage /></MainLayout></ProtectedRoute>} />
9180

92-
{/* 3. Register Docs Route */}
81+
9382
<Route path="/docs" element={
9483
<Docs />
9584
} />
9685

97-
{/* 2. Add Analytics Route */}
86+
9887
<Route path="/project/:projectId/analytics" element={
9988
<ProtectedRoute>
10089
<MainLayout>
@@ -103,13 +92,10 @@ function App() {
10392
</ProtectedRoute>
10493
} />
10594

106-
{/* 2. Register Auth Route */}
10795
<Route path="/project/:projectId/auth" element={<ProtectedRoute><MainLayout><Auth /></MainLayout></ProtectedRoute>} />
10896

109-
{/* 2. Register Settings Route */}
11097
<Route path="/settings" element={<ProtectedRoute><MainLayout><Settings /></MainLayout></ProtectedRoute>} />
11198

112-
{/* Project Specific Settings (New) */}
11399
<Route path="/project/:projectId/settings" element={<ProtectedRoute><MainLayout><ProjectSettings /></MainLayout></ProtectedRoute>} />
114100

115101

@@ -121,7 +107,6 @@ function App() {
121107
</ProtectedRoute>
122108
} />
123109

124-
{/* 2. Catch-all 404 Route (Sabse last mein hona chahiye) */}
125110
<Route path="*" element={<NotFound />} />
126111

127112
</Routes>

0 commit comments

Comments
 (0)