Feature/booking system - #47
Closed
Umeshinduranga wants to merge 7 commits into
Closed
Conversation
- Fixed Counselor.ts: Changed ref from 'User' to 'users' - Fixed Booking.ts: Changed ref from 'User' to 'users' - Fixed Progress.ts: Changed ref from 'User' to 'users' - Fixed Reminder.ts: Changed ref from 'User' to 'users' - Fixed Journal.ts: Changed ref from 'User' to 'users' These fixes ensure proper MongoDB population by using the correct registered model name.
- Modified getBookingById(): First find booking, then check ownership separately - Returns 403 Forbidden if user doesn't own the booking - Returns 404 Not Found if booking doesn't exist - Updated booking controller to handle 403 status code - Added same access control to cancelBooking() This ensures proper distinction between 'not found' and 'access denied' scenarios.
- Modified cancelBooking() to fetch booking without populate first - Checks ownership before attempting cancellation - Calls markSlotAsAvailable() with raw counselorId string - Returns populated booking in response for client context - Improved error handling in slot marking methods - Enhanced markSlotAsBooked() and markSlotAsAvailable() with try-catch This ensures slots are properly freed when bookings are cancelled.
- Added custom signUp endpoint for testing (POST /api/auth/register)
- Generates base64-encoded JSON tokens: {id, email, name, role}
- Updated isAuth middleware to support dual auth modes
- Tries BetterAuth sessions first, falls back to base64 tokens
- Decodes and validates base64 tokens against database user
- Registered /api/auth/register route in app.ts
This allows testing without BetterAuth while maintaining production compatibility.
- Added User model import for potential future use - Fixed specialty filter to use MongoDB operator - Specialty filter now correctly matches array elements - Improved error logging for debugging - Handles both 'specializations' and 'specialty' query parameters - Filter supports both single values and comma-separated lists This ensures specialty filtering works correctly across all counselor queries.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
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.
This pull request introduces several new features and improvements to the backend of the recovery system, focusing on user registration, counselor management, booking functionality, and data seeding. The changes collectively enhance the API by adding endpoints for booking sessions, managing counselors and their available slots, and supporting user registration for testing. Additionally, a script is provided to seed the database with test counselors and slots.
New Booking and Counselor Features:
booking.controller.ts).Counselor.controller.ts).User Registration and Authentication:
auth.controller.ts).app.ts). [1] [2] [3]Data Seeding and Testing:
seed-counselors.ts).API and Code Quality Improvements:
auth.controller.ts). [1] [2]app.ts).These changes significantly expand the backend's capabilities for managing counselors, bookings, and user accounts, and provide a solid foundation for testing and further development.