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,6 +1,6 @@
import { Context } from "elysia";
import prisma from "@/lib/prisma";
import path from "path";
import minio, { MINIO_BUCKET } from "@/lib/minio";
const musikDelete = async (context: Context) => {
const { id } = context.params as { id: string };
@@ -18,9 +18,7 @@ const musikDelete = async (context: Context) => {
// 2. HAPUS FILE AUDIO (jika ada)
if (musik.audioFile) {
try {
const fs = await import("fs/promises");
const filePath = path.join(musik.audioFile.path, musik.audioFile.name);
await fs.unlink(filePath);
await minio.removeObject(MINIO_BUCKET, `${musik.audioFile.path}/${musik.audioFile.name}`);
await prisma.fileStorage.delete({
where: { id: musik.audioFile.id },
@@ -33,9 +31,7 @@ const musikDelete = async (context: Context) => {
// 3. HAPUS FILE COVER (jika ada)
if (musik.coverImage) {
try {
const fs = await import("fs/promises");
const filePath = path.join(musik.coverImage.path, musik.coverImage.name);
await fs.unlink(filePath);
await minio.removeObject(MINIO_BUCKET, `${musik.coverImage.path}/${musik.coverImage.name}`);
await prisma.fileStorage.delete({
where: { id: musik.coverImage.id },