feat(core): Add endpoint GET /projects/:projectId/folders/:folderId/tree (no-changelog) (#13448)

This commit is contained in:
Ricardo Espinoza
2025-02-24 13:26:22 -05:00
committed by GitHub
parent b791677ffa
commit 06572efad3
4 changed files with 192 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
import { CreateFolderDto } from '@n8n/api-types';
import { Response } from 'express';
import { Post, RestController, ProjectScope, Body } from '@/decorators';
import { Post, RestController, ProjectScope, Body, Get } from '@/decorators';
import { FolderNotFoundError } from '@/errors/folder-not-found.error';
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
@@ -29,4 +29,23 @@ export class ProjectController {
throw new InternalServerError();
}
}
@Get('/:folderId/tree')
@ProjectScope('folder:read')
async getFolderTree(
req: AuthenticatedRequest<{ projectId: string; folderId: string }>,
_res: Response,
) {
const { projectId, folderId } = req.params;
try {
const tree = await this.folderService.getFolderTree(folderId, projectId);
return tree;
} catch (e) {
if (e instanceof FolderNotFoundError) {
throw new NotFoundError(e.message);
}
throw new InternalServerError();
}
}
}