Skip to content

Commit

Permalink
Remove console logs and streamline database connection handling; simp…
Browse files Browse the repository at this point in the history
…lify server listening logic in app.js
  • Loading branch information
0vai5 committed Jan 12, 2025
1 parent 18faeab commit 27ac1d2
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 10 deletions.
4 changes: 1 addition & 3 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,5 @@ app.get("/", (req, res) => {
export default serverless(app);

if (process.env.NODE_ENV !== "production") {
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
app.listen(port);
}
2 changes: 0 additions & 2 deletions server/config/db.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ const connectDB = async () => {
const db = await mongoose.connect(process.env.MONGO_URI)
connection.isConnected = db.connections[0].readyState;

console.log("Connection to database established");
} catch (error) {
console.log("error while connecting with mongodb", error);
process.exit(1);
}
};
Expand Down
4 changes: 0 additions & 4 deletions server/controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ export const userController = {
const user = await User.findById(id);

if (!user) throw new CustomError("User not found", 404);
console.log("done");
return res.status(200).json(new ApiResponse(200, "User found", user));
} catch (error) {
console.log(error);
return res
.status(error.status || 500)
.json(new ApiResponse(error.status || 500, error.message));
Expand Down Expand Up @@ -127,7 +125,6 @@ export const userController = {
.status(200)
.json(new ApiResponse(200, "User updated", updatedUser));
} catch (error) {
console.log(error);
return res
.status(error.status || 500)
.json(new ApiResponse(error.status || 500, error.message));
Expand Down Expand Up @@ -175,7 +172,6 @@ export const userController = {
async getCurrentUser(req, res) {
try {
const userId = req.user.id;
console.log("User ID from token:", userId);

const user = await User.findById(userId);

Expand Down
1 change: 0 additions & 1 deletion server/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ describe("User", () => {
token = response.data.token;
}
} catch (error) {
console.log("Error during sign-in:", error);
}
});

Expand Down

0 comments on commit 27ac1d2

Please sign in to comment.