feat: add Post category field and client-side image compression#286
Merged
3m1n3nc3 merged 1 commit intogeevapp:mainfrom Apr 24, 2026
Merged
Conversation
Closes geevapp#204 Closes geevapp#64 Issue geevapp#204 — Post category field - Add PostCategory enum (electronics, clothing, books, furniture, toys, food, sports, beauty, automotive, other) to schema.prisma - Add optional category field to Post model with @@index for fast filtering - Migration: 20260423000000_add_post_category - POST /api/posts now accepts and stores category - GET /api/posts already filtered by ?category= — now backed by the real field Issue geevapp#64 — Client-side image optimisation - New lib/image-compression.ts: compressImage() (max 0.5 MB / 1200×1200, WebP when supported, fallback JPEG), generateThumbnail() (300×300), formatFileSize() helper — all powered by browser-image-compression - Updated MediaUpload component: - Images compressed + thumbnail generated before upload - "Optimising…" overlay during compression, "Uploading…" during transfer - After upload: before/after size badge ("1.8 MB → 312 KB (−83%)") - Toast notification with savings summary - Falls back to original file on compression error
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.
Closes #204
Closes #64
What changed
#204 — Post
categoryfieldPostCategoryenum inschema.prisma:electronics,clothing,books,furniture,toys,food,sports,beauty,automotive,othercategory PostCategory?onPostmodel +@@index([category])20260423000000_add_post_categoryPOST /api/postsnow accepts and storescategoryGET /api/posts?category=electronicsnow filters against the real DB column#64 — Client-side image optimisation
lib/image-compression.ts:compressImage()(<500 KB, max 1200×1200, WebP/JPEG),generateThumbnail()(300×300),formatFileSize()MediaUploadupdated: compress → upload pipeline, "Optimising…" overlay, per-card savings label, toast with before/after sizes, silent fallback on errorHow to test
GET /api/posts?category=electronics