Open
Conversation
Update features, environment variables, and screenshots.
Anshu-rai89
requested changes
May 1, 2023
Collaborator
Anshu-rai89
left a comment
There was a problem hiding this comment.
Lets address all these comments as well optimizations
| const router = express.Router(); | ||
| const chatApi = require('../../../controllers/api/v1/chat_api'); | ||
|
|
||
| router.get('/:type/:sender/:receiver', chatApi.createChatRoom); |
Collaborator
There was a problem hiding this comment.
Add endpoint bluprint for all api endpoint
| let chatRoomId = data.sender + data.receiver; | ||
| let reverseChatRoomId = data.receiver + data.sender; | ||
|
|
||
| if (data.type == 'global') { |
Collaborator
There was a problem hiding this comment.
move this logic to saprate function. Move string to variable. Make it group and private
|
|
||
| module.exports.createChatRoom = async function (req, res) { | ||
| try { | ||
| const data = req.params; |
| module.exports.createChatRoom = async function (req, res) { | ||
| try { | ||
| const data = req.params; | ||
| console.log(data); |
| .exec(function (err, chatRoom) { | ||
| if (err) { | ||
| console.log('Error in finding chat room', err); | ||
| return res.status(500).json({ |
Collaborator
There was a problem hiding this comment.
Add error handling through middleware and error class
| try { | ||
| const data = req.params; | ||
| console.log(data); | ||
| let chatRoomId = data.sender + data.receiver; |
|
|
||
|
|
||
| // if the chat room already exists then return the chat room | ||
| ChatRoom.findOne({ chatRoomId: data.receiver + data.sender }) |
| }); | ||
| } else { | ||
| // create a new chat room | ||
| ChatRoom.create( |
Collaborator
There was a problem hiding this comment.
remove this lookup handle this at the time of creating a freind
| populate: { | ||
| path: 'sender', | ||
| }, | ||
| }) |
| // create a new chat room | ||
| ChatRoom.create( | ||
| { | ||
| chatRoomId: 'global', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.