portfolio addition in user profile #47
Merged
+1,475
−95
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.
Issue : #14
Have not made a separate schema for portfolio but added that in user profile schema...
Created API endpoints for managing user profiles, which include portfolio functionality:
POST /api/users/profile/:id/portfolio: Adds a portfolio item (title, URL, description) to a user's profile.
GET /api/users/profile/:id/portfolio: Retrieves all portfolio items for a user.
PUT /api/users/profile/:id/portfolio/:portfolioId: Updates an existing portfolio item for a user.
Ensured proper authorization by checking if the user is authenticated and if they are modifying their own profile. Unauthorized users receive a 403 status code.
User Authentication Middleware:
Implemented a middleware (authenticateUser) to authenticate users by verifying JWT tokens passed in the Authorization header.
The middleware ensures that only authenticated users can access certain routes, providing proper error handling for missing or invalid tokens.
Testing :
Added tests using Supertest to test the portfolio API functionalities, ensuring the creation, retrieval, and update of portfolio items work as expected.
Included tests for authentication and authorization, confirming that unauthorized users cannot modify another user's portfolio.