Skip to content

Conversation

@Priyamanjare54
Copy link

@Priyamanjare54 Priyamanjare54 commented Jan 17, 2026

📝 Description

Implemented full Labs CRUD functionality with authentication and authorization.Fixes #58

Key highlights:

  • Added Create, Read, Update, Delete APIs for Labs
  • Secured routes using JWT-based authentication
  • Ensured only the creator can update/delete their lab
  • Fixed MongoDB connection to support Prisma transactions using a replica set
  • Verified protected endpoints using Bearer token flow

This completes the Labs module backend functionality and prepares it for frontend integration.


🔗 Related Issue

Closes: N/A


🏷️ Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • 🎨 Style/UI update
  • ♻️ Code refactoring
  • ⚡ Performance improvement
  • 🧪 Test update

📸 Screenshots (if applicable)

N/A (Backend-only changes)


✅ Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have tested my changes locally
  • Any dependent changes have been merged and published

🧪 Testing

How I tested:

  • Generated JWT token via login

  • Tested protected endpoints using Authorization header

  • Verified ownership checks for update/delete

  • Confirmed Prisma works with MongoDB replica set

  • Tested API endpoints (Postman)

  • Tested on Chrome

  • Tested on Firefox

  • Tested on mobile


📋 Additional Notes

  • MongoDB replica set was configured locally to support Prisma transactions.
  • All endpoints return correct HTTP status codes (201, 403, 404, etc.).
  • Ready for frontend consumption.

SWOC 2026 Participant
Please add the swoc2026 label to this PR 🎉

Copy link
Owner

@tarinagarwal tarinagarwal left a comment

Choose a reason for hiding this comment

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

Great work on the Labs CRUD implementation! The core functionality is solid. A few improvements needed:

1. Use existing Prisma instance
Replace const prisma = new PrismaClient(); with import prisma from "../db.js"; to use the existing connection.

2. Add input validation

  • Validate required fields (title, language, difficulty, etc.)
  • Validate enum values for difficulty ("beginner", "intermediate", "advanced")
  • Validate visibility ("private", "public", "link")

3. Add filters to GET /api/labs
Add query parameter support for filtering by language, difficulty, creator, etc.

4. Minor fixes

  • Add newline at end of schema.prisma file
  • Add basic validation for empty/invalid ObjectIds

5. Error handling
Add validation for invalid ObjectId format in route parameters.

The MongoDB adaptations and ObjectId usage are perfect for this setup. Core CRUD logic and auth checks look excellent!

@Priyamanjare54
Copy link
Author

Hello, @tarinagarwal
I've completed the changes for Backend schema change #121
Please review when you have time. Happy to address any feedback!

@Priyamanjare54
Copy link
Author

Hello @tarinagarwal please review the changes

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.

AI Labs (1/6): Database Schema & Basic API

2 participants