feat: reference folders by their name

This commit is contained in:
diced
2026-05-24 18:58:06 -07:00
parent 6c94abc73b
commit e3789446c2
+5 -3
View File
@@ -20,7 +20,7 @@ export default typedPlugin(
PATH,
{
schema: {
description: 'Fetch a folder by ID. Behavior varies based on public and allowUploads flags.',
description: 'Fetch a folder by ID/name. Behavior varies based on public and allowUploads flags.',
params: z.object({
id: z.string(),
}),
@@ -45,8 +45,10 @@ export default typedPlugin(
async (req, res) => {
const { id } = req.params;
const folder = await prisma.folder.findUnique({
where: { id },
const folder = await prisma.folder.findFirst({
where: {
OR: [{ id }, { name: id }],
},
include: {
children: {
where: { public: true },