fix(api-v1): add soft-delete filters and remove any types in database operation routes

This commit is contained in:
charles-gauthereau
2026-05-25 15:18:55 +02:00
parent 39b6b5e116
commit 274aded8fd
3 changed files with 11 additions and 6 deletions
@@ -34,7 +34,7 @@ export const GET = withApiKey(
),
with: {
storages: {
where: (bs: any, { isNull: isNullFn }: any) => isNullFn(bs.deletedAt),
where: (bs, { isNull }) => isNull(bs.deletedAt),
},
},
});
+5 -3
View File
@@ -3,7 +3,7 @@ import { withApiKey, ApiKeyContext } from "@/lib/api-v1/middleware";
import { getAccessibleDatabaseIds } from "@/lib/api-v1/acl";
import { db } from "@/db";
import * as drizzleDb from "@/db";
import { eq, and } from "drizzle-orm";
import { eq, and, isNull } from "drizzle-orm";
import { z } from "zod";
import { logger } from "@/lib/logger";
@@ -53,7 +53,8 @@ export const POST = withApiKey(
const backupRecord = await db.query.backup.findFirst({
where: and(
eq(drizzleDb.schemas.backup.id, backupId),
eq(drizzleDb.schemas.backup.databaseId, id)
eq(drizzleDb.schemas.backup.databaseId, id),
isNull(drizzleDb.schemas.backup.deletedAt)
),
columns: { id: true },
});
@@ -66,7 +67,8 @@ export const POST = withApiKey(
const backupStorage = await db.query.backupStorage.findFirst({
where: and(
eq(drizzleDb.schemas.backupStorage.id, backupStorageId),
eq(drizzleDb.schemas.backupStorage.backupId, backupId)
eq(drizzleDb.schemas.backupStorage.backupId, backupId),
isNull(drizzleDb.schemas.backupStorage.deletedAt)
),
});
+5 -2
View File
@@ -3,7 +3,7 @@ import { withApiKey, ApiKeyContext } from "@/lib/api-v1/middleware";
import { getAccessibleDatabaseIds } from "@/lib/api-v1/acl";
import { db } from "@/db";
import * as drizzleDb from "@/db";
import { eq, desc } from "drizzle-orm";
import { eq, desc, and, isNull } from "drizzle-orm";
import { logger } from "@/lib/logger";
const log = logger.child({ module: "api/v1/databases/[id]/status" });
@@ -28,7 +28,10 @@ export const GET = withApiKey(
const [latestBackup, latestRestoration] = await Promise.all([
db.query.backup.findFirst({
where: eq(drizzleDb.schemas.backup.databaseId, id),
where: and(
eq(drizzleDb.schemas.backup.databaseId, id),
isNull(drizzleDb.schemas.backup.deletedAt)
),
orderBy: [desc(drizzleDb.schemas.backup.createdAt)],
}),
db.query.restoration.findFirst({