bytemakers / Noteslify

Your Privacy Friendly, Open Source. Alternative to EverNote.
GNU General Public License v3.0
125 stars 78 forks source link

removed unwanted data fields from API responses #261

Closed thevinitgupta closed 1 year ago

thevinitgupta commented 1 year ago

Describe your changes

Removed the unwanted data being send to the frontend from the API Also, replaced with success message where needed.

Screenshots - If Any (Optional)

Issue ticket number and link - If Any

217

Checklist before requesting a review

Additional Information (Optional)

devarshishimpi commented 1 year ago

@Gauravdarkslayer @abhinandanwadwa Kindly merge the PR after any of the two reviews completes!

Gauravdarkslayer commented 1 year ago

@thevinitgupta @devarshishimpi I guess the same thing goes for the folder section as well.

thevinitgupta commented 1 year ago

It is a const array. That is why I added a new array to return the required data.

thevinitgupta commented 1 year ago

@abhinandanwadwa shall I work on the folders route or wait for @devarshishimpi ?

abhinandanwadwa commented 1 year ago

@thevinitgupta Go ahead with folder routes

thevinitgupta commented 1 year ago

@abhinandanwadwa updated the folders routes.

devarshishimpi commented 1 year ago

Please use the delete key method I've mentioned earlier rather than creating a new array of objects.

@Gauravdarkslayer Is the required changes necessary or could we merge the PR?

Gauravdarkslayer commented 1 year ago

They are not necessary but its required for performance & space related optimizations. @devarshishimpi

devarshishimpi commented 1 year ago

They are not necessary but its required for performance & space related optimizations. @devarshishimpi

Great, @thevinitgupta Could you complete the required change as well?

thevinitgupta commented 1 year ago

@Gauravdarkslayer can I use the select method of the Schema prototype in this way :

const allNotes = await NoteSchema.find({ authorId: req.user.id, isDeleted: false }).select({_id : 1, title : 1, description : 1, createdAt : 1, secretKey : 1}).sort({ createdAt: -1 });

This way, we'll only need to delete the secretKey.

Gauravdarkslayer commented 1 year ago

@thevinitgupta Yes you can do this, but please make sure to be consistent throughout the application. Like if you are doing this for notes routes and do the same for folder routes as well.

thevinitgupta commented 1 year ago

I have added the select query and used the delete key method for the notes and folders routes.