Skip to content

Fix/journal frontend - #54

Merged
Umeshinduranga merged 7 commits into
mainfrom
fix/journal_frontend
Mar 21, 2026
Merged

Fix/journal frontend#54
Umeshinduranga merged 7 commits into
mainfrom
fix/journal_frontend

Conversation

@Umeshinduranga

Copy link
Copy Markdown
Collaborator

This pull request introduces significant improvements to the journal feature in the backend, focusing on more robust file upload handling, improved validation, and new analytics endpoints. The changes include a new flexible image upload service with local disk fallback, enhanced input validation and parsing for journal entries, and a new endpoint for user writing statistics. Additionally, the codebase is refactored for better clarity and maintainability, with improved error handling and route organization.

Journal feature enhancements:

  • Added a new /api/journals/stats endpoint to provide users with aggregated writing statistics, including total entries, word count, top mood, writing streak, and mood distribution. [1] [2]
  • Improved input validation for journal entries: stricter checks for content length, mood values, and robust parsing of array fields from various input formats.
  • Enhanced error handling and response consistency across all journal controller methods.

File upload and static file serving:

  • Refactored the upload service to support both Cloudinary and local disk storage, including automatic directory creation and file type/size validation. The backend now serves uploaded images from /uploads when Cloudinary is not configured, making them accessible to the frontend. [1] [2]
  • Added a helper function getFileUrl to generate correct public URLs for uploaded images, supporting both Cloudinary and local disk scenarios. [1] [2]

API and route organization:

  • All journal routes now require authentication by default, and the /journals/stats endpoint is registered before parameterized routes to avoid conflicts.
  • Improved code organization and comments for clarity, grouping middleware and route registrations by theme, and clarifying CORS and static file serving configuration.

These changes make the journal API more robust, secure, and flexible for both development and production environments.

@vercel

vercel Bot commented Mar 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
re-life-website Ignored Ignored Mar 21, 2026 7:01am

@Umeshinduranga Umeshinduranga left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewed

@Umeshinduranga Umeshinduranga added the enhancement New feature or request label Mar 21, 2026
@Umeshinduranga
Umeshinduranga merged commit 9996a37 into main Mar 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants