Skip to content

Conversation

@Akalanka47000
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Nov 25, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
bashaway-backend Ignored Ignored Nov 25, 2025 2:25pm

Copilot finished reviewing on behalf of Akalanka47000 November 25, 2025 14:25
Copy link

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 adds database-level auditing functionality to track changes made to the User, Submission, and Question models. The implementation uses the @sliit-foss/mongoose-audit plugin with express-http-context to capture the user making each change.

  • Added audit plugin integration to User, Submission, and Question schemas
  • Modified repository methods to ensure audit hooks are triggered properly
  • Set up context middleware to track the authenticated user for audit logging

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/helpers/audit.js Created audit helper that configures the mongoose-audit plugin with user context retrieval
src/models/user.js Added audit plugin to User schema
src/models/submission.js Added audit plugin to Submission schema
src/models/question.js Added audit plugin to Question schema
src/middleware/auth.js Set authenticated user in express-http-context for audit tracking
src/repository/submission.js Changed from Submission.create() to new Submission().save() to trigger audit hooks
src/repository/question/index.js Changed from Question.deleteOne() to Question.findOneAndDelete() for audit trail
src/constants/index.js Added ctxUser constant for context key
src/app.js Removed unused pick import from lodash
package.json Added @sliit-foss/mongoose-audit dependency and packageManager field

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


export const deleteAQuestion = (filters) => {
return Question.deleteOne(filters);
return Question.findOneAndDelete(filters);
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The findOneAndDelete method should have a .lean() call for consistency with other query methods in this file, or it should return the deleted document if needed for audit purposes. Currently, this returns a Mongoose document while other methods return plain JavaScript objects.

Suggested change
return Question.findOneAndDelete(filters);
return Question.findOneAndDelete(filters).lean();

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants