feat(29-01): extract dominant color in image upload endpoints

Both POST /api/images and POST /api/images/from-url now return
dominantColor in their response body.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-12 19:56:34 +02:00
parent e305fa7ae5
commit 2696b78f9e

View File

@@ -2,7 +2,10 @@ import { randomUUID } from "node:crypto";
import { zValidator } from "@hono/zod-validator";
import { Hono } from "hono";
import { z } from "zod";
import { fetchImageFromUrl } from "../services/image.service";
import {
extractDominantColor,
fetchImageFromUrl,
} from "../services/image.service";
import { uploadImage } from "../services/storage.service";
const ALLOWED_TYPES = ["image/jpeg", "image/png", "image/webp"];
@@ -59,7 +62,10 @@ app.post("/", async (c) => {
const buffer = await file.arrayBuffer();
await uploadImage(Buffer.from(buffer), filename, file.type);
return c.json({ filename }, 201);
// Extract dominant color for adaptive background fill
const dominantColor = await extractDominantColor(buffer);
return c.json({ filename, dominantColor }, 201);
});
export { app as imageRoutes };