Skip to content

feat: add Post category field and client-side image compression#286

Merged
3m1n3nc3 merged 1 commit intogeevapp:mainfrom
OpenSourceCOntr:feat/issues-204-64-category-image-compression
Apr 24, 2026
Merged

feat: add Post category field and client-side image compression#286
3m1n3nc3 merged 1 commit intogeevapp:mainfrom
OpenSourceCOntr:feat/issues-204-64-category-image-compression

Conversation

@Uchechukwu-Ekezie
Copy link
Copy Markdown

Closes #204
Closes #64

What changed

#204 — Post category field

  • PostCategory enum in schema.prisma: electronics, clothing, books, furniture, toys, food, sports, beauty, automotive, other
  • category PostCategory? on Post model + @@index([category])
  • Migration: 20260423000000_add_post_category
  • POST /api/posts now accepts and stores category
  • GET /api/posts?category=electronics now filters against the real DB column

#64 — Client-side image optimisation

  • New lib/image-compression.ts: compressImage() (<500 KB, max 1200×1200, WebP/JPEG), generateThumbnail() (300×300), formatFileSize()
  • MediaUpload updated: compress → upload pipeline, "Optimising…" overlay, per-card savings label, toast with before/after sizes, silent fallback on error

How to test

  • Create a post with a category — verify stored and returned in GET
  • Filter: GET /api/posts?category=electronics
  • Upload a large image — observe compression overlay and savings badge

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
@3m1n3nc3 3m1n3nc3 merged commit baa9e8e into geevapp:main Apr 24, 2026
2 checks passed
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.

Add Post category field to schema — referenced in forms but missing from model Feature: Implement client-side image optimization and compression

2 participants