Skip to content

Dintzeler solution#57

Open
dintzeler wants to merge 41 commits into
GlobalWebIndex:mainfrom
dintzeler:dintzeler_solution
Open

Dintzeler solution#57
dintzeler wants to merge 41 commits into
GlobalWebIndex:mainfrom
dintzeler:dintzeler_solution

Conversation

@dintzeler

Copy link
Copy Markdown

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:

  • Implemented controllers for authentication and favorite asset management, supporting GET, POST, DELETE, and PATCH operations on /favorites and login via /auth. These controllers handle request validation, error responses, and interact with service logic. [1] [2]

Authentication and middleware:

  • Added JWT authentication 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:

  • Defined models for assets (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:

  • Added a Dockerfile for containerization and updated go.mod for dependency management. The main entry point (main.go) loads environment variables and sets up routing. [1] [2] [3]

Documentation and usability:

  • Overhauled README.md to provide detailed instructions, API documentation, environment setup, test structure, and Docker usage for easy onboarding and deployment.

…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.
… functionality

test: add comprehensive tests for login functionality and response validation

test: move error response validation to a dedicated helper function
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.

1 participant