fix(storage): migrate domain-specific delete and update handlers to MinIO

- Replaces local filesystem operations (fs.unlink, path.join) with MinIO removeObject in all domain lib handlers
- Updated handlers for: Berita, GalleryFoto, Layanan, Musik, Penghargaan, Potensi, Profile, Inovasi, Keamanan, Kesehatan, LandingPage, and PPID
- bump: version 0.1.19 -> 0.1.20
This commit is contained in:
2026-04-23 17:05:44 +08:00
parent 37940fc7e2
commit b9d43eb723
41 changed files with 97 additions and 191 deletions

View File

@@ -1,7 +1,6 @@
import prisma from "@/lib/prisma";
import fs from "fs/promises";
import { Context } from "elysia";
import path from "path";
import minio, { MINIO_BUCKET } from "@/lib/minio";
const posyanduDelete = async (context: Context) => {
const id = context.params?.id as string;
@@ -28,8 +27,7 @@ const posyanduDelete = async (context: Context) => {
// Hapus file gambar dari filesystem jika ada
if (posyandu.image) {
try {
const filePath = path.join(posyandu.image.path, posyandu.image.name);
await fs.unlink(filePath);
await minio.removeObject(MINIO_BUCKET, `${posyandu.image.path}/${posyandu.image.name}`);
await prisma.fileStorage.delete({
where: { id: posyandu.image.id },
});