Skip to content

Conversation

Avdhesh-Varshney
Copy link
Member

Closes: #1241

Type of change ☑️

What sort of change have you made:

  • Bug fix
  • Code style update (formatting, local variables)
  • Documentation update

@Avdhesh-Varshney Avdhesh-Varshney self-assigned this Sep 28, 2025
@Avdhesh-Varshney Avdhesh-Varshney added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 28, 2025
Copy link

vercel bot commented Sep 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
code-a2z Error Error Sep 28, 2025 3:16pm

Copy link

Thank you for submitting your pull request! We'll review it as soon as possible. For further communication, join our discord server https://discord.gg/tSqtvHUJzE.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR encompasses a comprehensive code style and documentation update, transitioning the project structure from frontend/backend to client/server nomenclature while standardizing code formatting across JavaScript and TypeScript files.

Key changes include:

  • Renamed project directories from frontend/backend to client/server
  • Applied consistent code formatting with single quotes, proper trailing commas, and standardized spacing
  • Updated package.json configurations and build scripts to reflect the new naming convention

Reviewed Changes

Copilot reviewed 221 out of 235 changed files in this pull request and generated 6 comments.

File Description
server/src/**/*.js Updated all server-side JavaScript files with consistent formatting (single quotes, trailing commas, proper indentation)
client/src/**/*.ts Applied TypeScript formatting standards with single quotes and proper type definitions
package.json Updated scripts and configuration to use client/server naming and added comprehensive formatting commands
docs/ Added new documentation for submodule addition, setup procedures, and formatting guidelines
Files not reviewed (1)
  • server/package-lock.json: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +10 to 59
Project.findOneAndUpdate(
{ _id },
{ $inc: { 'activity.total_likes': incrementVal } }
)
.then(project => {
if (!project) {
return sendResponse(res, 404, "error", "Project not found", null);
return sendResponse(res, 404, 'error', 'Project not found', null);
}

if (!islikedByUser) {
const like = new Notification({
type: "like",
type: 'like',
project: _id,
notification_for: project.author,
user: user_id
user: user_id,
});

like.save()
.then(notification => {
return sendResponse(res, 200, "success", "Project liked successfully", { liked_by_user: true });
});
like.save().then(notification => {
console.log('New like notification created', notification._id);
return sendResponse(
res,
200,
'success',
'Project liked successfully!',
{ liked_by_user: true }
);
});
} else {
Notification.findOneAndDelete({ type: "like", project: _id, user: user_id })
Notification.findOneAndDelete({
type: 'like',
project: _id,
user: user_id,
})
.then(() => {
return sendResponse(res, 200, "success", "Project unliked successfully", { liked_by_user: false });
return sendResponse(
res,
200,
'success',
'Project unliked successfully',
{ liked_by_user: false }
);
})
.catch(err => {
return res.status(500).json({ error: err.message });
});
}
})
.catch(err => {
return sendResponse(res, 500, "error", err.message, null);
return sendResponse(res, 500, 'error', err.message, null);
});
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The like.save().then() promise is not properly handled. The response is being sent inside the .then() callback but there's no .catch() error handling, and the function doesn't await or return this promise chain.

Copilot uses AI. Check for mistakes.

Comment on lines +63 to +88
Comment.findOne({ _id }).then(comment => {
if (!comment) {
return sendResponse(res, 404, 'error', 'Comment not found', null);
}
if (
user_id === comment.commented_by?.toString() ||
user_id === comment.project_author?.toString()
) {
deleteComments(res, _id);
return sendResponse(
res,
200,
'success',
'Comment deleted successfully',
null
);
} else {
return sendResponse(
res,
403,
'error',
'You are not authorized to delete this comment',
null
);
}
});
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

Missing .catch() error handler for the MongoDB findOne operation. Database operations should always include error handling to prevent unhandled promise rejections.

Copilot uses AI. Check for mistakes.

.then(project => {
console.log('New comment created')
});
new Comment(commentObj).save().then(async commentFile => {
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The async keyword inside a .then() callback is problematic. Either use async/await pattern consistently or use promise chains, but mixing them can lead to unexpected behavior and unhandled promise rejections.

Copilot uses AI. Check for mistakes.

title
.replace(/[^a-zA-Z0-9]/g, ' ')
.replace(/\s+/g, '-')
.trim() + nanoid();
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The string concatenation with nanoid() has unclear operator precedence. Consider wrapping the title manipulation in parentheses: (title.replace(...).trim()) + nanoid() for better readability.

Suggested change
.trim() + nanoid();
(.trim()) + nanoid();

Copilot uses AI. Check for mistakes.

fullname: "",
profile_img: "",
name: "",
access_token: null,
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The User interface expects access_token to be string | null, but the empty state sets it to null. Consider using an empty string '' instead for consistency with other string fields, or update the interface to clearly handle null states.

Suggested change
access_token: null,
access_token: '',

Copilot uses AI. Check for mistakes.

@Avdhesh-Varshney Avdhesh-Varshney temporarily deployed to avdhesh/doc-update - code-a2z PR #1253 September 28, 2025 15:16 — with Render Destroyed
@Avdhesh-Varshney Avdhesh-Varshney merged commit 21e7b45 into main Sep 28, 2025
1 of 3 checks passed
@Avdhesh-Varshney Avdhesh-Varshney deleted the avdhesh/doc-update branch September 28, 2025 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Docs & Setup Guidelines

1 participant