style: clean up code with prettier and eslint

This commit is contained in:
openhands committed 2026-07-12 20:31:05 +02:00
1 parent 60278b9e71
commit fb8e77bb68
378 files changed
+22407 -20689

No files matched your search

@@ -1,23 +1,25 @@
import { revalidateTag } from 'next/cache'
import { NextResponse } from 'next/server'
import { withAdmin } from '@/lib/api-handler'
import { apiError } from '@/lib/api-response'
import { PERMS } from '@/lib/permissions'
import { prisma } from '@/lib/prisma'
import { revalidateTag } from "next/cache";
import { NextResponse } from "next/server";
import { withAdmin } from "@/lib/api-handler";
import { apiError } from "@/lib/api-response";
import { PERMS } from "@/lib/permissions";
import { prisma } from "@/lib/prisma";
export const POST = withAdmin({ permission: PERMS.PERMISSIONS_MANAGE }, async (request) => {
const body = await request.json()
const userId = Number(body.userId)
const roleId = Number(body.roleId)
const body = await request.json();
const userId = Number(body.userId);
const roleId = Number(body.roleId);
if (!Number.isInteger(userId) || userId <= 0 || !Number.isInteger(roleId) || roleId <= 0) {
return apiError('Valid userId and roleId required', 400)
return apiError("Valid userId and roleId required", 400);
}
if (body.action === 'remove') {
await prisma.aclModelRole.deleteMany({ where: { modelType: 'User', modelId: userId, roleId } })
if (body.action === "remove") {
await prisma.aclModelRole.deleteMany({ where: { modelType: "User", modelId: userId, roleId } });
} else {
const existing = await prisma.aclModelRole.findFirst({ where: { modelType: 'User', modelId: userId, roleId } })
if (!existing) await prisma.aclModelRole.create({ data: { modelType: 'User', modelId: userId, roleId } })
const existing = await prisma.aclModelRole.findFirst({
where: { modelType: "User", modelId: userId, roleId },
});
if (!existing) await prisma.aclModelRole.create({ data: { modelType: "User", modelId: userId, roleId } });
}
revalidateTag('permissions', { expire: 0 })
return NextResponse.json({ success: true })
})
revalidateTag("permissions", { expire: 0 });
return NextResponse.json({ success: true });
});
+27 -24
View File
@@ -1,31 +1,34 @@
import { revalidateTag } from 'next/cache'
import { NextResponse } from 'next/server'
import { withAdmin } from '@/lib/api-handler'
import { apiError } from '@/lib/api-response'
import { PERMS } from '@/lib/permissions'
import { prisma } from '@/lib/prisma'
import { revalidateTag } from "next/cache";
import { NextResponse } from "next/server";
import { withAdmin } from "@/lib/api-handler";
import { apiError } from "@/lib/api-response";
import { PERMS } from "@/lib/permissions";
import { prisma } from "@/lib/prisma";
export const POST = withAdmin({ permission: PERMS.PERMISSIONS_MANAGE }, async (request) => {
const body = await request.json()
const slug = String(body.slug ?? '').trim().toLowerCase()
const title = String(body.title ?? '').trim()
if (!/^[a-z0-9._-]{2,64}$/.test(slug) || !title) return apiError('Valid slug and title required', 400)
const role = await prisma.aclRole.create({ data: { slug, title } })
revalidateTag('permissions', { expire: 0 })
return NextResponse.json({ role })
})
const body = await request.json();
const slug = String(body.slug ?? "")
.trim()
.toLowerCase();
const title = String(body.title ?? "").trim();
if (!/^[a-z0-9._-]{2,64}$/.test(slug) || !title) return apiError("Valid slug and title required", 400);
const role = await prisma.aclRole.create({ data: { slug, title } });
revalidateTag("permissions", { expire: 0 });
return NextResponse.json({ role });
});
export const DELETE = withAdmin({ permission: PERMS.PERMISSIONS_MANAGE }, async (request) => {
const id = Number(request.nextUrl.searchParams.get('id'))
if (!Number.isInteger(id) || id <= 0) return apiError('Valid ID required', 400)
const role = await prisma.aclRole.findUnique({ where: { id }, select: { slug: true } })
if (!role) return apiError('Role not found', 404)
if (role.slug.startsWith('rank_')) return apiError('Rank roles must be managed through emulator ranks', 409)
const id = Number(request.nextUrl.searchParams.get("id"));
if (!Number.isInteger(id) || id <= 0) return apiError("Valid ID required", 400);
const role = await prisma.aclRole.findUnique({ where: { id }, select: { slug: true } });
if (!role) return apiError("Role not found", 404);
if (role.slug.startsWith("rank_"))
return apiError("Rank roles must be managed through emulator ranks", 409);
await prisma.$transaction([
prisma.aclModelPermission.deleteMany({ where: { modelType: 'Role', modelId: id } }),
prisma.aclModelPermission.deleteMany({ where: { modelType: "Role", modelId: id } }),
prisma.aclModelRole.deleteMany({ where: { roleId: id } }),
prisma.aclRole.delete({ where: { id } }),
])
revalidateTag('permissions', { expire: 0 })
return NextResponse.json({ success: true })
})
]);
revalidateTag("permissions", { expire: 0 });
return NextResponse.json({ success: true });
});