-
Notifications
You must be signed in to change notification settings - Fork 347
Guidelines & doc update #1253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guidelines & doc update #1253
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
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. |
There was a problem hiding this 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/backendtoclient/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.
| 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); | ||
| }); |
Copilot
AI
Sep 28, 2025
There was a problem hiding this comment.
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.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 | ||
| ); | ||
| } | ||
| }); |
Copilot
AI
Sep 28, 2025
There was a problem hiding this comment.
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 => { |
Copilot
AI
Sep 28, 2025
There was a problem hiding this comment.
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(); |
Copilot
AI
Sep 28, 2025
There was a problem hiding this comment.
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.
| .trim() + nanoid(); | |
| (.trim()) + nanoid(); |
Copilot uses AI. Check for mistakes.
| fullname: "", | ||
| profile_img: "", | ||
| name: "", | ||
| access_token: null, |
Copilot
AI
Sep 28, 2025
There was a problem hiding this comment.
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.
| access_token: null, | |
| access_token: '', |
Copilot uses AI. Check for mistakes.
Closes: #1241
Type of change ☑️
What sort of change have you made: