-
Notifications
You must be signed in to change notification settings - Fork 23
Fix: Improve data integrity, validation, and performance across models & APIs #12
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
Open
theniteshdev
wants to merge
56
commits into
JavaScript-Mastery-Pro:main
Choose a base branch
from
theniteshdev:fix/bughunt-theniteshdev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
c97f95b
fix: use ObjectId for teacherId reference
theniteshdev a34e2a4
fix: restrict audience with enum values
theniteshdev dd9f090
feat: add compound indexes for teacherId and pinned queries to improv…
theniteshdev d419ed8
fix: replace teacherId string with ObjectId reference
theniteshdev 93125d9
fix: add validation for title, description, subject, and class fields
theniteshdev 07e9f16
fix: enforce deadline to be in the future
theniteshdev 89e8c8d
fix: add constraints to maxMarks field
theniteshdev 2f5d289
feat: add indexes for performance optimization
theniteshdev ed44128
fix: change attendance date type from string to Date
theniteshdev d4fe8e1
fix: strengthen unique index with teacherId
theniteshdev 9e9c614
fix: replace teacherId with ObjectId reference
theniteshdev bababd3
fix: remove redundant studentName and class fields
theniteshdev dd0b2ec
fix: improve attendance schema consistency and data integrity
theniteshdev 9186586
fix: replace teacherId with ObjectId reference
theniteshdev eb1dace
fix: remove redundant studentName
theniteshdev d12bc5e
fix: add enum validation for subject and term fields
theniteshdev 2c48ed0
fix: define subject field type with enum validation
theniteshdev fcf5426
fix: add type and default value for term field
theniteshdev 6e0aaba
fix: restore studentName field to prevent data inconsistency issues
theniteshdev fef2da7
fix: add trimming to required student fields to ensure data consistency
theniteshdev 4d4e8da
fix: add email format validation to student schema
theniteshdev ecb9abe
fix: normalize optional student fields by adding trimming
theniteshdev be7c74f
fix: normalize rollNo to uppercase to enforce uniqueness consistency
theniteshdev 56ad31b
fix: add index for teacherId and class to optimize student queries
theniteshdev b5aa1a0
fix: enforce minimum length validation on required student fields
theniteshdev f259b72
fix: add trimming to teacher fields for data consistency
theniteshdev 22dab3e
fix: add email format validation to teacher schema
theniteshdev 2f6f66d
fix: validate subjects array to prevent empty or invalid values
theniteshdev a9b06a0
fix: add trimming to academicHistory fields
theniteshdev ac53676
fix: normalize optional teacher fields by adding trimming
theniteshdev 39fab09
fix: add indexes for department and subjects to improve query perform…
theniteshdev 3601932
fix: add missing await for findOneAndUpdate in grades POST endpoint
theniteshdev e415ec1
fix: provide default value for maxMarks to prevent runtime errors
theniteshdev 7706a23
fix: correct grade calculation boundary for A+ grade
theniteshdev 0eef839
fix: validate studentId as a valid MongoDB ObjectId
theniteshdev 9511c9a
fix: convert studentId to ObjectId in GET query for correct filtering
theniteshdev dab7aea
fix: prevent exposure of internal error stack in API response
theniteshdev cf32081
fix: normalize input fields by trimming strings before database opera…
theniteshdev d0a8b67
fix: handle null currentUser to prevent creating invalid teacher records
theniteshdev cf3581b
fix: strengthen input validation by trimming string fields
theniteshdev 20e910e
fix: validate subjects array to prevent empty or invalid values
theniteshdev fd57eab
fix: normalize input data before updating teacher profile
theniteshdev 78912f0
fix: enable schema validation in findOneAndUpdate operation
theniteshdev 4998e95
fix: trim optional fields before updating teacher profile
theniteshdev c7ce708
fix: resolve teacher ObjectId from clerkId for correct grade queries …
theniteshdev 5299665
fix: Enhance subjects validation in profile route
theniteshdev 7ffd902
fix: Change teacherId type to ObjectId in Announcement model and remo…
theniteshdev d03cbf2
Refactor: teacherId type and update schema fields
theniteshdev dc4009c
refactor: Attendance model to use ObjectId and remove fields
theniteshdev cad1c1d
remove: studentName from IAttendance interface
theniteshdev cecc46f
Change teacherId type from string to ObjectId
theniteshdev 077de99
fix: email validation and update unique index
theniteshdev 7a799a3
Refactor teacher lookup into a separate function
theniteshdev 9038946
Enhance studentId validation in grades route
theniteshdev 7095a26
fix: validation for subjects array in route.ts
theniteshdev 6978b98
Update route.ts
theniteshdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,42 @@ | ||
| import mongoose, { Schema, model, models } from 'mongoose' | ||
| import mongoose, { Schema, model, models } from "mongoose"; | ||
|
|
||
| export interface IAnnouncement { | ||
| _id: mongoose.Types.ObjectId | ||
| teacherId: string | ||
| title: string | ||
| content: string | ||
| audience: string | ||
| category: 'academic' | 'events' | 'admin' | 'general' | ||
| pinned: boolean | ||
| createdAt: Date | ||
| updatedAt: Date | ||
| _id: mongoose.Types.ObjectId; | ||
| teacherId: mongoose.Types.ObjectId; | ||
| title: string; | ||
| content: string; | ||
| audience: string; | ||
| category: "academic" | "events" | "admin" | "general"; | ||
| pinned: boolean; | ||
| createdAt: Date; | ||
| updatedAt: Date; | ||
| } | ||
|
|
||
| const AnnouncementSchema = new Schema<IAnnouncement>( | ||
| { | ||
| teacherId: { type: String, required: true, index: true }, | ||
| title: { type: String, required: true }, | ||
| content: { type: String, required: true }, | ||
| audience: { type: String, default: 'All' }, | ||
| category: { type: String, enum: ['academic', 'events', 'admin', 'general'], default: 'general' }, | ||
| teacherId: { | ||
| type: Schema.Types.ObjectId, | ||
| ref: "Teacher", | ||
| required: true, | ||
| index: true, | ||
| }, | ||
| title: { type: String, required: true, trim: true, minlength: 3 }, | ||
| content: { type: String, required: true, trim: true, minlength: 5 }, | ||
| audience: { type: String, default: "All", trim: true }, | ||
| category: { | ||
| type: String, | ||
| enum: ["academic", "events", "admin", "general"], | ||
| default: "general", | ||
| }, | ||
| pinned: { type: Boolean, default: false }, | ||
| }, | ||
| { timestamps: true } | ||
| ) | ||
| { timestamps: true }, | ||
| ); | ||
|
|
||
| AnnouncementSchema.index({ teacherId: 1, pinned: 1 }); | ||
|
|
||
| AnnouncementSchema.index({ teacherId: 1, createdAt: -1 }); | ||
|
|
||
| export const Announcement = | ||
| models.Announcement ?? model<IAnnouncement>('Announcement', AnnouncementSchema) | ||
| models.Announcement ?? | ||
| model<IAnnouncement>("Announcement", AnnouncementSchema); |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.