Dintzeler solution#57
Open
dintzeler wants to merge 41 commits into
Open
Conversation
…rs, and favorites
…rite function, and implement data loading for favorites
…ser ID and asset details, and implement data loading for favorites
…GetById function and update data store to use pointers for charts, insights, and audiences
…implifying nil checks for charts, insights, and audiences
…s.AssetType, implement user favorites retrieval, and add asset existence checks
…e delete and update favorite functions to include user ID and description, and improve data persistence
…readability and consistency in the favorites service
…kage, streamline favorite existence checks, and enhance asset description updates
…n name and move route setup to a dedicated routes package
…alidators package, implement validation logic for asset ID and type, and update handleAddFavorite function to utilize new validation
…rite function and validation logic, introducing structured validation errors for improved clarity
… for improved error handling in favorite operations
…atus and error, enhance error handling in favorite addition process
…lude user ID, asset ID, and asset type; modify handleAddFavorite function to return structured response
… pointer to FavoritesResponse and an error; enhance error handling for data loading
…audiences; update CreateFavorite function to accept user ID, asset ID, and asset type directly
…th structured error responses; implement validation for delete requests
…e functions; enhance request validation and error handling
…on; change HTTP method from PUT to PATCH; enhance error handling in UpdateFavorite function
…pdate data loading to use environment variable for data file path; add unit tests for favorites functionality
…ecific GetChartById, GetInsightById, and GetAudienceById functions; update buildFavoritesResponse to use new retrieval methods
…se; validate response and persistence in data file
…ith enhanced validation; update response structure and error handling; add comprehensive unit tests for UpdateFavorite
…stErrorResponse and testInvalidUserID functions; add TestDeleteFavorite with comprehensive test cases for deletion scenarios; update test data description for consistency
…for uniqueness; update verification to match new description format; add generateRandomNDigitNumber function
- Added JWT middleware for protecting routes. - Created authentication routes for user login. - Implemented user authentication service to validate credentials and generate JWT. - Updated user model to include password field. - Enhanced favorites routes to require authentication. - Added validation for login requests. - Updated test cases to include authentication checks. - Modified test data to reflect new user credentials and descriptions.
…orites functionality
… functionality test: add comprehensive tests for login functionality and response validation test: move error response validation to a dedicated helper function
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 a new Go-based web service for managing user favorite assets, including charts, insights, and audiences. The changes implement core API endpoints, authentication via JWT, local JSON storage, Docker support, and comprehensive documentation. The project is structured for maintainability and extensibility, with clear separation of concerns across controllers, models, middleware, and services.
Core functionality and API endpoints:
/favoritesand login via/auth. These controllers handle request validation, error responses, and interact with service logic. [1] [2]Authentication and middleware:
middleware/jwt_authenticator.go) to secure endpoints and extract user context from tokens. This ensures only authenticated users can manage their favorites.Data modeling and storage:
Chart,Insight,Audience), users, favorites, and supporting types. The service uses a local JSON file (data.json) for persistent storage of assets, users, and favorites. [1] [2] [3] [4] [5] [6] [7]Project setup and environment:
Dockerfilefor containerization and updatedgo.modfor dependency management. The main entry point (main.go) loads environment variables and sets up routing. [1] [2] [3]Documentation and usability:
README.mdto provide detailed instructions, API documentation, environment setup, test structure, and Docker usage for easy onboarding and deployment.