🚨 fix: resolve linting type error

This commit is contained in:
Rafi Arrafif
2026-01-31 09:03:32 +07:00
parent 68fec64efc
commit fd8f980d9a
3 changed files with 3 additions and 5 deletions

View File

@ -14,17 +14,13 @@ export async function generateSlug(
const baseSlug = slugify(input, { lower: true, strict: true });
let uniqueSlug = baseSlug;
// CASE 1: Tidak ada config → langsung return slug
if (!config) return uniqueSlug;
const { model, target } = config;
// CASE 2: Validasi pasangan model-target
if (!model || !target) {
throw new Error(`Both "model" and "target" must be provided together.`);
}
// CASE 3: Cek unique
const prismaModel = (prisma as any)[model];
if (!prismaModel) {
throw new Error(`Model "${model as string}" not found in PrismaClient.`);